-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: NamedQuery and custom Types with JPA
PostPosted: Tue Apr 19, 2011 2:11 am 
Newbie

Joined: Mon Apr 18, 2011 11:58 am
Posts: 3
Hi,

i use an Entity with a field "startTime". This field is of an own datatype Time. To let Hibernet know how to handle with this field it is annotated with:

Code:
@Type(type = "de.abc.def.PersistentTime")


The Class PersistentTime implements org.hibernate.usertype.UserType and mapps between my own Time and java.sql.Date in the database.

This works great as long as i don't use named queries:

Code:
@NamedQueries({
    @NamedQuery(name = "test.abc.query", query = "SELECT tab FROM Table tab"
            + "WHERE tab.startTime > :startTime") })


In this case JPA can not resolve the mapping and i get an exception:

Code:
java.lang.IllegalArgumentException: Parameter value [de.abc.def.time.Time@5c97bbb1] was not matching type [java.sql.Date]


Has anyone an idea how to get JPA able to map between my type and the database? Maybe there is a possibility to configure this mapping globaly?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.