-->
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.  [ 3 posts ] 
Author Message
 Post subject: Can't store row with DB2 Sequence
PostPosted: Mon Mar 22, 2004 11:46 am 
Newbie

Joined: Mon Mar 22, 2004 11:36 am
Posts: 7
Hi,


I am trying create an Database row, where the id is selected from db2
sequence but it doesnt work. i had already store a row in the DB2 but
with hibernate uuid. I have search the forum and read the doku but
i didnt find a suitable example.

Any hints are welcome

I have the followed situation. Code

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="net.bla.enterprise.test.CatSeq" table="Log.CatSeq">
<id name="id" type="long" unsaved-value="null" >
<generator class="sequence">
<param name="sequence">Log.cat_seq</param>
</generator>
</id>
<property name="name"/>
<property name="sex"/>
<property name="weight"/>
</class>
</hibernate-mapping>


package net.bla.enterprise.test;

public class CatSeq {
private long id;
private String name;
private char sex;
private float weight;
public CatSeq() {
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public char getSex() {
return sex;
}
public void setSex(char sex) {
this.sex = sex;
}
public float getWeight() {
return weight;
}
public void setWeight(float weight) {
this.weight = weight;
}
}


My Test call

net.sf.hibernate.Session hiberSess=HibernateUtil.currentSession();
try{
Transaction tx = hiberSess.beginTransaction();
CatSeq princess = new CatSeq();
princess.setName("Princess");
princess.setSex('F');
princess.setWeight(7.4f);
hiberSess.save(princess);
tx.commit();

}catch(HibernateException e)
{
e.printStackTrace();
out.println(e.getMessage());
}
HibernateUtil.closeSession();


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 4:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
but it doesnt work


It is very flattering that you think we are psychics and geniuses, but the sad fact is that we actually need you to give us some kind of useful information before we can help you resolve problems.


http://www.hibernate.org/ForumMailingli ... AskForHelp


Top
 Profile  
 
 Post subject: I will make more effort next time, before I ask!!
PostPosted: Tue Mar 23, 2004 5:16 am 
Newbie

Joined: Mon Mar 22, 2004 11:36 am
Posts: 7
It is very flattering that you think we are psychics and geniuses, but the sad fact is that we actually need you to give us some kind of useful information before we can help you resolve problems.


http://www.hibernate.org/ForumMailingli ... AskForHelp[/quote]

I now reading that.[/b]


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