-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Issue with hibernate inheritance subclass not using sequence
PostPosted: Mon May 12, 2014 1:21 pm 
Newbie

Joined: Mon May 12, 2014 7:51 am
Posts: 1
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;
}


}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.