-->
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.  [ 6 posts ] 
Author Message
 Post subject: <param> tag inside a <generator> tag
PostPosted: Mon Apr 05, 2004 3:03 am 
Newbie

Joined: Mon Apr 05, 2004 2:50 am
Posts: 17
Hello,

I am using my own classe to generate a sequence ID. With the new version of hibernate (1.2.1) it doesn't seems to take in consideration the <param> tag. My "HibernateSequenceGen.class" has got a construct with one parameter. This parameter is a string and the the name is "sequenceName".

With the previous version of Hibernate it was working perfectly, but in that previous version the < name=".."> property of the <param> tag was not requiered.

Do you have any Idea ?



Here my configuration


<id name="sid" type="long" unsaved-value="0">
<generator class="mypackage.HibernateSequenceGen">
<param name="sequenceName">c_group</param>
</generator>
</id>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 05, 2004 9:18 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Can you clarify your problem and what is going on ?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 05, 2004 2:53 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 1:24 pm
Posts: 213
Location: Richardson, TX
I'm using the <param> tag inside a <generate> (with my own custom ID generator) in the most recent version (2.1.2) with no problems. What error are you getting?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 05, 2004 7:41 pm 
Newbie

Joined: Mon Apr 05, 2004 2:50 am
Posts: 17
Hello,

Yes I will try :) to clarify my problem. I am using my own class to generate an ID. I have to pass a sequence Name to my class to be able to generate a different ID for a different sequence.

My own class has two constructors :

First constructor
------------------


public HibernateSequenceGen() throws HibernateException {
log.debug("HibernateSequenceGen default");
this.sequenceName = "__DEFAULT__";
getHome();
log.info("HibernateSequenceGen default OK");
}


Second constructor
------------------

public HibernateSequenceGen(String sequenceName) throws HibernateException {
log.debug("HibernateSequenceGen: "+sequenceName);
this.sequenceName = sequenceName;
getHome();
}


When I use this classe in an hibernate mappings xml file as follow, It never calls my second constructor but always the first one.

<id name="sid" type="long" unsaved-value="0">
<generator class="com.webmcq.ld.util.sequence.HibernateSequenceGen">
<param name="sequenceName">cm_ld_content_key</param>
</generator>
</id>

It seems that it never take in consideration the <param> tag in my <generator> tag. Normally by specify an <param> it must calls the constructor with param and not the default one.

The other possibility is that I have not understood something :)

I hope that is more clear :)


Thanks for your answers.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 11:45 am 
Pro
Pro

Joined: Tue Aug 26, 2003 1:24 pm
Posts: 213
Location: Richardson, TX
First thing, does your HibernateSequenceGen class extend one of the classes in the net.sf.hibernate.id package or implement net.sf.hibernate.id.Configurable? To use parameters you need to implement the configure() method in your class. Here's an example of an implementation: (in a class that extends net.sf.hibernate.id.SequenceGenerator)
Code:
public void configure(
                      Type type,
                      Properties params,
                      Dialect dialect
                     )
               throws MappingException {
    super.configure(
                    type,
                    params,
                    dialect
                   );
    String fooProperty = params.getProperty("foo");
}

This would set the <param> "foo".


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 10:24 pm 
Newbie

Joined: Mon Apr 05, 2004 2:50 am
Posts: 17
Thanks greg_barton it is working fine with your solution.


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