-->
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.  [ 5 posts ] 
Author Message
 Post subject: [JPA] Prevent entity management within a transaction?
PostPosted: Wed Oct 22, 2008 11:06 am 
Newbie

Joined: Thu Jul 10, 2008 9:42 am
Posts: 4
Hibernate version: 3.2.6.ga via hibernate-entitymanager (JPA) using maven2

I have some entities that I consider to be read-only. They are JPA entities and ALL columns have insertable=false, updatable=false. However, the queries have to run inside of a transaction.

Is there any further way to ensure that the entities are not converted for management since I won't be updating them, but cannot operate outside of a transaction?

Can entities reside in the Hibernate first-tier cache as read-only if hibernate is dis-allowed from doing the extra work that is done to manage updatable entities?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2008 1:43 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
If you are loading the entities with a HQL query you can call Query.setReadOnly(true) before executing the query. Unfortunately there seems to be no method with the same functionality for Criteria queries.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2008 2:27 pm 
Newbie

Joined: Thu Jul 10, 2008 9:42 am
Posts: 4
nordborg wrote:
If you are loading the entities with a HQL query you can call Query.setReadOnly(true) before executing the query. Unfortunately there seems to be no method with the same functionality for Criteria queries.


We are trying to stick with coding against neutral JPA. and unfortunately neither javax.persistence.Query nor JPA named queries expose this property.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2008 3:36 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Ok. Another option is to mark the class with mutable="false", but I think that is also a Hibernate extension.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2008 4:01 pm 
Newbie

Joined: Thu Jul 10, 2008 9:42 am
Posts: 4
nordborg wrote:
Ok. Another option is to mark the class with mutable="false", but I think that is also a Hibernate extension.


Actually, that is a better option. Annotations are used in one place (per entity), so it's easier to manage the migration away from hibernate specifics in this case. I'll see how far that gets me. Thanks!


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