Hi all,
I have a problem with the automatic generation of a Sequence in a Oracle Database.
I have configured a class who uses a component as ID.
I want to use a sequence to raise this ID.
I have configured it as follow:
In my main class (table)
@Entity
@Table(name = "users")
@SequenceGenerator(name = "SEQ_USER_STORE", sequenceName = "user_seq", allocationSize = 2)
public class User{
private UserID m_id;
...
// here also @EmbeddedId is the same result
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_USER_STORE")
public UserID getId()
{
return m_id;
}
}
My component:
@Embeddable
public class UserID{
private Integer m_id;
@Column(name = "id", length = 10)
public Integer getId()
{
return m_id;
}
}
I also have on both classes the methods, hashCode, Equals, toString implemented
in my mapping file (hibernate.cfg.xml) i have
<mapping class="myPackage.User" />
and my oracle connection settings
Now when i run the ant "schema-recreate" from the org.hibernate.tool.ant.HibernateToolTask the table is created succesfully but no sequence is created.
When i try to add a record i get the message "Id's for this class must be manually assigned before calling the save method"
Can someone help me out of this problem, is this a bug or a configuration problem on my side.
Are there any examples for using a component as ID with a sequence?
Any support wil be appriciated.
Thanks in advance
Some details:
hibernate.version=3.2.5
hibernate-annotations.version=3.3.0
hibernate-commons-annotations.version=3.0.0
hibernate-tools.version=3.3.0
database: Oracle 10g
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
|