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