-->
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: A few questions regarding AdminApp
PostPosted: Mon Jan 19, 2004 6:34 pm 
Newbie

Joined: Sun Oct 26, 2003 4:46 pm
Posts: 16
Location: Tallinn, Estonia
Hello,

I am reading the AdminApp sources (0.9.1). First of all - a brilliant piece of work - very easy to follow. Thanks Gavin for this excellent sample of Hibernate+WebWork2.

A few questions that remained a bit unclear for me:

User and Role have their IDs defined as java.lang.Long. However in the HBM there is this:
Code:
      <id name="id" column="USER_ID"
         unsaved-value="0">
         <!-- primitive int, so use
            unsaved-value="0". -->
         <generator class="increment"/>
      </id>

Shouldn't the 'unsaved-value' be 'null' in this case?

What is actually the recommended way: have IDs as primitives or objects? What are the implications of either approach?

Also regarding caching:

In Role.hbm.xml therw is:
Code:
      <!-- there are few roles, and they are 
         not updated so cache them -->
      <cache usage="read-only"/>

If you define this 'read-only' but nevertheless write some objects (as is the case with roles) what happens? No problems if it is not a cluster?

Also in hibernate.cfg.xml there is:
Code:
      <class-cache
         class="org.hibernate.admin.model.Role"
         region="Role"
         usage="read-write"/>

I couldn't find anything in the docs about this. Isn't the 'read-write' conflicting with the Role.hbm.xml?

best regards,
erik


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2004 12:16 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The identifer unsaved value is indeed wrong, thanks for spotting this. It has no effect in the current application (no detached objects), luckily. There is actually not much difference between a primitive and an object identifier type, just use whatever you like.

The cache setting in hibernate.cfg.xml overrides the setting in the mapping file, I added a comment. The read-only strategy works fine as long as you only _save_ objects, but never _update_ them.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.