-->
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: more SequenceStyleGenerator, and a possible bug ( ? )
PostPosted: Fri May 04, 2007 10:50 am 
Newbie

Joined: Thu Feb 09, 2006 12:37 pm
Posts: 18
Hi all,
I have a table in a mySQL db representing a sequence, that has a varchar column, and a long column, the varchar is the name of the sequence, the long the current sequence value.

I have set up my hibernate mappings as so (Do i need to do this for each mapping? or is there a global point i can do this?):
Code:
   <class name="User" table="cmt_006_user">
      <id name="OID" column="OID">
         <generator class="org.hibernate.id.enhanced.SequenceStyleGenerator">
            <param name="sequence_name">cmt_000_sequence</param>
            <param name="sequence">CACSeq</param>
            <param name="optimizer">none</param>
            <param name="increment_size">1</param>
            <param name="value_column">CurrentValue</param>           
         </generator>


if i add <param name="inital_vale">-9223372036854775808</param>
I get a number format exception whilst trying to deploy, as the generator is using a parseInt method, even if I add an L to the end to indicate a long as you would in Java, (This is the possible bug??).

I am trying to insert into the user DB using this code:
Code:
public class UserDaoHb extends HibernateDaoSupport implements UserDao
{
   protected final Log _logger = LogFactory.getLog(getClass());

   public boolean insertUser(User user)
   {
      this._logger.info("Creating user: "+user.getOID());
      Transaction tx = this.getSession().beginTransaction();
   this._logger.info("Inside create");
   this._logger.info("attempting hibernate insert");
   this.getSession().save(user);
   this._logger.info("attempt finished");     
      tx.commit();
   return false;
   }
}


What happens is that the code just go into a loop trying to get an ID, whilst actual managing to update the sequnce, the logging shows an "infinite" loop of:

Code:
2007-05-04 15:46:04,677 DEBUG [org.hibernate.jdbc.AbstractBatcher] - opening JDBC connection
2007-05-04 15:46:04,677 DEBUG [org.hibernate.SQL] - select CurrentValue id_val from cmt_000_sequence for update
2007-05-04 15:46:04,677 DEBUG [org.hibernate.SQL] - update cmt_000_sequence set CurrentValue= ? where CurrentValue=?
2007-05-04 15:46:05,224 DEBUG [org.hibernate.jdbc.AbstractBatcher] - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)


No new user is inserted into the user table.
[/code]

I am using Spring MVC, and configuring hibernate though the application context.

Any ideas?
Thanks
Gavin


Top
 Profile  
 
 Post subject: It is a Bug
PostPosted: Tue May 08, 2007 10:36 am 
Newbie

Joined: Thu Feb 09, 2006 12:37 pm
Posts: 18
My code works fine when switching to native key generation, not ideal, but i can live with it.

So its a bug, or my sequence table is some how not good enough, or the xml mapping is wrong.


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.