cancel
Showing results for 
Search instead for 
Did you mean: 

EJB CMP Find By Date Field - How to do?

Former Member
0 Kudos

HI ALL,

I got a question about EJB CMP develpment.

Let say I created a table with Java dictionary as follows

column name: ID, built-in type: String

column name: PR_DATE, built-in type: date

column name: DESC, built-in type: String

Then I develop a EJB-CMP as follows:

CMP field: id, type: java.lang.String

CMP field: prDate, type: java.util.Date

CMP field: desc, type: java.lang.String

And I want to develop and findByPrDate Method:

java.util.Collection findByPrDate(java.util.Date)

EJB-QL: select object(p) from PRBean p where p.prDate = ?1

The problem is when I deploy the EJB, it got the warning:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Reason: Clusterwide exception: server ID 19282450:com.sap.engine.services.ejb.exceptions.deployment.ORMappingVerificationException: The Java type of the cmp-field that is stored in column PR_DATE, table WPR_PR_TBL does not fit to the JDBC type DATE of the column. The expected JDBC type is TIMESTAMP. The acceptable JDBC types for the columns in which the cmp-fields of CMPBeans are stored are described in the O/R mapping requirements.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Since I read the documentation that if a date field appear in EJB-QL, the type must be java.util.Date, but seems if using java.util.Date as CMP field and the table is using 'date', then will give above error.

Anyone encounter this before and any solution?

Thanks a lot !

Kelvin

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member182372
Active Contributor
0 Kudos

Hi,

Accroding to http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/EJBQL6.html

<i>Date and time values are in milliseconds and use a Java long. A date or time literal should be an integer literal. To generate a millisecond value, you may use the java.util.Calendar class.

</i>

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

java.util.Date is not supported, you have to use java.sql.Date for all date fields

Kiran

Former Member
0 Kudos

Hi,

Don't know if it helps but try java.sql.Date instead of java.util.Date

Good luck, Roelof