cancel
Showing results for 
Search instead for 
Did you mean: 

@Embeddable with java.uitil.Date in JPQL (limitations ?)

Former Member
0 Kudos

I'm facing with problem regarding using java.util.Date in JPQL query.

Here are sample entities for test case:


@Embeddable
public class EmbCompTest implements Serializable{
		
	private static final long serialVersionUID = 1L;

	@Temporal(TemporalType.DATE)
	private Date beginPeriod;
	
	@Temporal(TemporalType.DATE)
	private Date endPeriod;

                   // getters and setters goes here (...)

	
}


@Entity
@Table(name="TEST_DATE")
@NamedQueries(
	{
   @NamedQuery(name="getByDate",query="select e from TestDate e where e.beginDate=:beginDatePm"),
   @NamedQuery(name="getByDate2",query="select e from TestDate e where e.emb.beginPeriod=:beginPeriodPm")
}
)
public class TestDate {

	private static final long serialVersionUID = 6651720114733319974L;
      
	@Id
	private Long id;

	@Temporal(TemporalType.DATE)
	private Date beginDate;
	
	@Temporal(TemporalType.DATE)
	private Date endDate;
	
	@Embedded
	private EmbCompTest emb;

                     // getters and setters goes here (...)
	
	
}

The problem is in named query getByDate2 which causes persistence unit fail to start with exception

Caused by: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Method must not be called with

argument "java.util.Date" or "java.util.Calendar"

Is that some SAP JPA limitation that makes unable to query by date defined in @Embeddable classes ?

Of course query getByDate works fine.

Best Regards

Daniel

Accepted Solutions (0)

Answers (2)

Answers (2)

adrian_goerler
Active Participant
0 Kudos

Hi,

a patch will be available with the releases 7.11 SP 5 and 7.20 SP 3 of the NetWeaver Java EE Server.

-Adrian

adrian_goerler
Active Participant
0 Kudos

Hi Daniel,

the query getByDate2 is OK and should work. This looks like a bug to me. If you have access to OSS, please file a ticket on BC-JAS-PER-JPA.

Have you tried typing beginPeriod with java.sql.Date. This might work. (I have not tried).

-Adrian

Former Member
0 Kudos

Hello

many thanks for your opinion. I've reported a problem to sap service.

BTW java.sql.Date is problematic with model which may be exposed by web services.

Best Regards

Daniel