Hi all,
I'm using Hibernate annotation to generate sequence number in Oracle 10g database, but i get this error message while trying to insert to the SubClass:
"Unable to insert to TrxLog Header: org.springframework.dao.InvalidDataAccessResourceUsageException: could not get next sequence value; nested exception is org.hibernate.exception.SQLGrammarException: could not get next sequence value"
Here, i use a class TrxLog and sub class ExtendedTrxLog, here's part of the structure:
Quote:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "dType", discriminatorType = DiscriminatorType.INTEGER)
@DiscriminatorValue(value = "0")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class TrxLog implements Serializable {
private int id;
private String trxCode;
@Id
@SequenceGenerator(name = "id_sequence", sequenceName = "sq50")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "id_sequence")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTrxCode() {
return trxCode;
}
public void setTrxCode(String trxCode) {
this.trxCode = trxCode;
}
}
@Entity
@DiscriminatorValue(value="5")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ExtendedTrxLog extends TrxLog {
private double amount;
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
}
There's also a trigger for TrxLog table
Quote:
BEGIN
if :NEW.ID is null
then SELECT sq50.nextval INTO :NEW.ID FROM dual;
end if;
END;
Any idea? sory for any mistakes, I'm still a newbie here
Thanks,
Felix