Hi all,
I'm attempting to put some base functionality in a base class for all persistent entities. To that end I must be able to call get/setId on all entities so I put an abstract definition of such in the base class:
Code:
@Id
public abstract Serializable getId();
public abstract void setId(Serializable id);
The type is Serializable because some classes have compound keys.
Then in a subclass:
Code:
@Column(name="id", insertable=false, updatable=false)
@org.hibernate.annotations.Type(type="java.lang.Long")
@javax.persistence.SequenceGenerator(name = "generator", allocationSize = 1)
@javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.SEQUENCE, generator = "generator")
@Override
public Serializable getId() {
return this.id;
}
@Override
public void setId(Serializable id) {
this.id = (Long)id;
}
what this gets me is an error stating that I have to set the id manually, as if it doesn't recognize the generation strategy. I've previously defined all annotations on the subclass, and gotten errors indicating that hibernate is trying to do an insert with the ID field listed twice (duplicate column).
Has anyone gotten something similar to this to succeed?
Hibernate: 3.5.5 Final in JPA 'mode'
Database: Oracle 10g
Java: 6