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.
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.
Any support wil be appriciated
Thanks in advance
Some details:
Hibernate version:3.2.5
Name and version of the database you are using: Oracle
|