Hi My Super class is having Primary key and in my Sub class Entity I want to define/use Sequencer defined in Oracle database but I am always getting value of ID(Primary Key) as 0.It seems sequencer is not getting executed.Please help.
@MappedSuperclass public abstract class GenericEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id @Column(name = "ID") protected long id;
@Version protected Integer version = Integer.valueOf(0);
public GenericEntity() { }
public abstract long getId() ;
public void setId(long id) { this.id = id; }
}
Sub Class:
@Entity @Table(name = "pf_address") @SequenceGenerator(sequenceName="SEQ_PF_ADDRESS", name = "seq_address", allocationSize=1) public class Address extends GenericEntity { private static final long serialVersionUID = 5627302335705194341L; private String country = "";
@GeneratedValue(generator= "seq_address", strategy = GenerationType.SEQUENCE) @AttributeOverride(name = "id", column = @Column(name = "ID")) public long getId() { return id; }
return country; }
public void setCountry(String country) { this.country = country; }
}
|