-->
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: changing generator class at runtime
PostPosted: Sat Jan 05, 2008 7:46 am 
Newbie

Joined: Tue Oct 24, 2006 6:24 am
Posts: 7
dear hibernate gurus!

is it possible to change properties from the mapping at runtime? in my case i have the following mapping xy.hbm.xml

Code:
<class name="User" table="user">
  <id name="id" column="ID" type="long">
    <generator class="native"/>
  </id>
....a.s.o.


this works fine, no problem. the needed id is generated automatically.
BUT:
if i want to write the id field on my own, there is no way (for example if i want to import an exact database dump, with correct ids). i have to change the generator class from 'native' to 'assigned' by hand in each mapping file.
So the question is:
when i start my application with the arg -import, all generator classes should be changed to 'assigned'.
i've searched in Hibernate Mapping API (ClassMetadata, PersistentClass,...) without any success.

please help (with code snippets if possible).
thx in advance

Hibernate version:3.2


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 06, 2008 5:36 am 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
yes, you can provide your own generator class, it only has to implement an interface, check the reference documentation 5.1.4.1. Generator

_________________
Gonzalo Díaz


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.