Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] How to generate the PK?

Hi,
I have an object that is representing a Table. It has a numeric primary key and each time a record is created it is incremented by 1.
How to define this in the Object mapping?

I have used the following:
@Entity
@Table(name = "vmlo.certificate")
public class Certificate implements Serializable {
    private static final long serialVersionUID = 1L;
    private int certKeyfield;
    private String certBrowserName;

    public Certificate() {
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "CertKeyfield")
    public int getCertKeyfield() {
        return this.certKeyfield;
    }

    public void setCertKeyfield(int certKeyfield) {
        this.certKeyfield = certKeyfield;
    }
.
.
Using this I am getting an exception from my JPA provider EclipseLink:
<Error> <EJB> <BEA-010026> <Exception occurred during commit of transaction Name=[EJB com.thunderhead.simple.SimpleBean.process(int)],Xid=BEA1-0660A26EF337BD76B51F(9378830),Status=Rolled back. [Reason=weblogic.transaction.internal.AppSetRollbackOnlyException],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=60,SCInfo[wl_server+examplesServer]=(state=rolledback),properties=({weblogic.transaction.name=[EJB com.thunderhead.simple.SimpleBean.process(int)]}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=examplesServer+192.168.2.165:7001+wl_server+t3+, XAResources={examples-demoXA, WLStore_wl_server_WseeFileStore, examples-demoXA-2, WLStore_wl_server_exampleJDBCStore, examples-multiDataSource-demoXAPool, WLStore_wl_server__WLS_examplesServer},NonXAResources={})],CoordinatorURL=examplesServer+192.168.2.165:7001+wl_server+t3+): weblogic.transaction.RollbackException: Unknown reason
at weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1818)
at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:333)

It does not explain the reason for exception. However, is it due to the reason that the PK generation is not happening or the EclipseLink does not know how to generate this PK? Is the GenerationType.IDENTITY is wrong to generate PK for this type?

Please help.

--
Tanujit Chowdhury

Back to the top