Hi folks,
Please excuse me if this question has been asked before. I have searched for a hint/solution but must've searched for the wrong keywords. I'm not entirely sure how to find this.
I have an abstract class which contains a number of things, one of which is the Id property. All the other entities extends this class. I previously used the traditional XML mapping and this worked just fine. However, I would like to get rid of the XML files and move all the mapping into annotations.
Here's what I have:
Code:
@MappedSuperclass
public abstract class AbstractObject implements Serializable {
@Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
private long id = 0;
public long getId(){return id;}
private void setId(long id){
this.id = id;
}
//....some other stuff...
}
@Entity
public class Photo extends AbstractObject {
private static final long serialVersionUID = 0;
public Photo(){}
@ManyToOne
@JoinColumn(name="dogID")
private Dog dog;
public Dog getDog(){return dog;}
public void setDog(Dog dog){
this.dog = dog;
}
@Lob
@Column(columnDefinition="bytea")
private byte[] image;
public byte[] getImage(){return image;}
public void setImage(byte[] image){
this.image = image;
}
}
This works okay for reading data from the DB. However, it fails when I try to persist entities. I'm using PostgreSQL and, since I have not specified the sequence name, it's looking for the default "hibernate_sequence".
Can someone please help me with this? I need to know how to specify the sequence name.
Any hints/suggestions will be greatly appreciated.
Many thanks,
Dany.