-->
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.  [ 6 posts ] 
Author Message
 Post subject: java.lang.UnsupportedOperationException: cannot perform look
PostPosted: Tue Mar 29, 2005 9:50 am 
Newbie

Joined: Mon Mar 21, 2005 7:27 pm
Posts: 2
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:hibernate-3.0rc1

Mapping documents:"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
java.lang.UnsupportedOperationException: cannot perform lookups on timestamps
at org.hibernate.type.TimestampType.getHashCode(TimestampType.java:99)
at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:119)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:162)
at org.hibernate.engine.EntityKey.getHashCode(EntityKey.java:68)
at org.hibernate.engine.EntityKey.<init>(EntityKey.java:41)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:136)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:429)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:424)
at com.bjrichtime.common.HotelLog.saveLog(HotelLog.java:73)
at com.bjrichtime.common.HotelLog.log(HotelLog.java:62)
at com.bjrichtime.common.HotelLog.log(HotelLog.java:67)
at com.bjrichtime.common.HotelLog.main(HotelLog.java:85)
Exception in thread "main"


Name and version of the database you are using:MySQl 4.018

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 29, 2005 10:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read the stack trace.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Is these a way to make it possible?
PostPosted: Fri Apr 22, 2005 4:48 am 
Newbie

Joined: Fri Apr 22, 2005 4:33 am
Posts: 9
Yes, I know what the exception is trying to say. The question is whether there is a way to make including a timestamp field in composite-id possible or not.

If it is possible, please tell me how to do it or refer me to the doc which describes it. Otherwise, just tell us that it is not possible to do it in Hibernate3 because I can do it in Hibernate2.

Thanks.

BTW, I know there is the implementation of TimestampType to not support performing lookups on timestamps by the following code segment,

Code:
public int getHashCode(Object x, EntityMode entityMode) {
    throw new UnsupportedOperationException("cannot perform lookups on timestamps");
}


Top
 Profile  
 
 Post subject: I finally found the solution
PostPosted: Fri Apr 22, 2005 5:46 am 
Newbie

Joined: Fri Apr 22, 2005 4:33 am
Posts: 9
Actually, it is not possible to include a field with "timestamp" type in your composite-id because the TimestampType did not support it by nature(it did not support the getHashCode method) and it should not support it due to the different timestamp handling mechanisms by database vendors.

However, I resolve this issue by changing the type from "timestamp" to "calendar" in my Hibernate's mapping files which means that I also have to change the type from "java.util.Date" to "java.util.Calendar" in my POJOs.

--------------------------------------- MAPPING FILES

Code:
    <property
        name="approveDate"
        type="date"
        column="APRV_DT"
        not-null="true"
        >
    </property>


to

Code:
    <property
        name="approveDate"
        type="calendar"
        column="APRV_DT"
        not-null="true"
        >
    </property>


--------------------------------------- POJOS

Code:
    private Date _approveDate;


to

Code:
    private Calendar _approveDate;


I verified it by running my testcases passed. I hope it is helpful to you because I also encountered this issue and took a while to figure it out.


Top
 Profile  
 
 Post subject: You may also find that this entry is helpful
PostPosted: Fri Apr 22, 2005 5:48 am 
Newbie

Joined: Fri Apr 22, 2005 4:33 am
Posts: 9
http://forum.hibernate.org/viewtopic.php?t=940213


Top
 Profile  
 
 Post subject: Re: I finally found the solution
PostPosted: Fri Apr 22, 2005 7:39 am 
Newbie

Joined: Thu Apr 21, 2005 12:20 pm
Posts: 4
Quote:
[I verified it by running my testcases passed. I hope it is helpful to you because I also encountered this issue and took a while to figure it out.


Thanks a lot, it solved my problem.

Morten Simonsen


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

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.