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.  [ 4 posts ] 
Author Message
 Post subject: @formula annoation difficulties
PostPosted: Wed Nov 30, 2005 6:41 am 
Newbie

Joined: Tue Jun 14, 2005 12:44 pm
Posts: 19
Hi there
I have am using hibernate annotation. I would like to create a read-only calculated field which comprises of the difference between the end and start dates, which are both mapped fields in my annotation.

After reviewing the docs, I tried to do this:


Code:
@Column(name="Started")
   private Date started;

   @Column(name="Ended")
   private Date ended;
@Formula ("ended - started")
private Date duration;



This does NOT work - after running the query, I receive this exception:
Caused by: org.hibernate.AnnotationException: java.util.Date collection not yet supported: com.prod.repository.Sessionduration


Any idea as to how to corerctly define and use the @formula annotation??

Thanks
E.


Hibernate version:
3.1
Mapping documents:

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

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 1:04 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I find this error hard to believe.
Debug you code to find the offending declaration.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: the problem continues - any help?
PostPosted: Thu Dec 01, 2005 4:17 am 
Newbie

Joined: Tue Jun 14, 2005 12:44 pm
Posts: 19
Thank you for your informative reply.
I am grateful for the time you took out to assist me.

It seems that *EVERY* variable I have tried to use with the @formula annotation has given me this exception - ints, shorts, whatever. I have tried putting SQL statements in the formula or just place column numbers - the result is the same.


ANy idea?
Code:
Caused by: org.hibernate.AnnotationException: int collection not yet supported: com.xx.rep.Sessiontest


Any other informative replies will be extremely welcome!

E.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 7:37 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
the only way I can see that happen is if you add @OneTOMany or @ManyToMany on formula.
Use your debugger to see what happen in HA

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.