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.  [ 2 posts ] 
Author Message
 Post subject: self-referencing classes
PostPosted: Wed Feb 20, 2008 11:52 am 
Newbie

Joined: Fri Feb 15, 2008 4:46 am
Posts: 5
Location: UK
I have a number of public static finals in my classes and need to save and retrieve them from Hibernate as table rows. If I reference a public static final and save, Hibernate creates an instance of the class as a row in the table. However, if I run the application again and retrieve that row, it is not associated in anyway to the public static final. Referencing the static final again creates a new row. Is it possible to map these correctly?

Ann

_________________
Ann


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 22, 2008 12:12 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
I don't know why you would want an entity class to expose another entity as a static property, but in any case, you would have to load these static properties in the class's static constructor. I don't see how NHibernate is going to know to load (or save) them, as they are static. Being static, they are not associated with any particular instance.

Let's take the example of an ApplicationUser entity class. Rather than expose the application's currently logged in user as a static property on the ApplicationUser entity class, it should be exposed as an instance property on a separate singleton class, say ApplicationSession.


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