Hi guys,
I'm using Hibernate with Oracle10g. My class is mapped to a table. This table id is incremented by an oracle Trigger+sequence.
As soon as i do a save(Obj), the object is correctly saved, a new id is created, but hibernate does not return it...
Here is my bean :
Code:
@Entity
@Table(name = "FAVORITE", schema = "scem", uniqueConstraints = @UniqueConstraint(columnNames = {
"FAV_U_LOGIN", "FAV_TITLE" }))
public class Favorite implements java.io.Serializable {
private long favId;
private Utilisateur utilisateur;
private String favTitle;
private Clob favText;
public Favorite() {
}
public Favorite(long favId) {
this.favId = favId;
}
public Favorite(long favId, Utilisateur utilisateur, String favTitle,
Clob favText) {
this.favId = favId;
this.utilisateur = utilisateur;
this.favTitle = favTitle;
this.favText = favText;
}
@Id
@Column(name = "FAV_ID", unique = true, nullable = false, precision = 22, scale = 0)
public long getFavId() {
return this.favId;
}
public void setFavId(long favId) {
this.favId = favId;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "FAV_U_LOGIN")
public Utilisateur getUtilisateur() {
return this.utilisateur;
}
public void setUtilisateur(Utilisateur utilisateur) {
this.utilisateur = utilisateur;
}
@Column(name = "FAV_TITLE", length = 30)
public String getFavTitle() {
return this.favTitle;
}
public void setFavTitle(String favTitle) {
this.favTitle = favTitle;
}
@Column(name = "FAV_TEXT")
public Clob getFavText() {
return this.favText;
}
public void setFavText(Clob favText) {
this.favText = favText;
}
@Transient
public String getFavTextString(){
return FormatConverter.JavaClob.clobToString(favText);
}
public void setFavTextString(String text){
favText = FormatConverter.JavaClob.stringToClob(text);
}
}
Here is my DAO code
Code:
public PK saveObj(T o) {
PK obj = (PK) getSession().save(o);
System.out.println("ID : " + obj);
return obj;
Do I have something special to do ?
I tryed to use @GeneratedValue and @SequenceGenerator.
When i use Oracle sequence driven by Hibernate, it works.. But that's not what i want to do.
When i try to specify that i'm using a trigger(i guess with generator="select") it doesn't work.
Thanks.