cancel
Showing results for 
Search instead for 
Did you mean: 

Bigdecimal as PrimaryKey Type in Entity

Former Member
0 Kudos

Hi,

I am using Netweaver CE 7.1 for deploying a test application. My Entity has a Bigdecimal field as Primary key. While deploying the applcation I am getting following exception :

<b>

Primary Keys Check: Primary key 'actRmatId' of class 'entity.Activities' cannot be of type 'java.math.BigDecimal'. Allowed types are: Java primitive types; any primitive wrapper type; java.lang.String; java.util.Date; java.sql.Date; byte[], file: TestEJB.jar#META-INF/persistence.xml, column 0, line 0, severity: error</b>

Can anybody please tell me, why Bigdecimal is restricted in this version of netweaver while it was working fine in NetWeaver Application Server, Java(TM) EE 5 Edition...

My Application is using Bigdecimal because of the precision requirements. Is there a way to use Entities with Bigdecimal as primary key types in CE7.1.

Thanks ,

Prasoon.

Accepted Solutions (1)

Accepted Solutions (1)

adrian_goerler
Active Participant
0 Kudos

Hi Prasoon,

with CE 7.1, we introduced a check that asserts that the IDs obey the +recomendations +expressed by the JPA specification § 2.1.4:

+The primary key (or field or property of a composite primary key) should be one of the following types:

any Java primitive type; any primitive wrapper type; java.lang.String; java.util.Date;

java.sql.Date. In general, however, approximate numeric types (e.g., floating point types) should

never be used in primary keys. Entities whose primary keys use types other than these will not be portable.

If generated primary keys are used, only integral types will be portable. If java.util.Date is

used as a primary key field or property, the temporal type should be specified as DATE.+

This check rejects BigDecimal fields. It is probably to strict. We will likely lift the restriction with the next release.

Unfortunately, I am not aware of any workaround to disable the check.

Best regards,

Adrian Görler

Former Member
0 Kudos

Hi Adrian,

Thanks a lot for your reply.

Missed that part in JPA specification.

I think we might need to make necessary changes in our application or wait for next release .

Thanks,

Prasoon

Answers (0)