Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Trouble with getter annotations in entities(What determines where eclipselink will look for @Column, @Temporal and @Id annotations?)
Trouble with getter annotations in entities [message #1751436] Tue, 10 January 2017 11:09 Go to next message
Ivan Petrov is currently offline Ivan PetrovFriend
Messages: 2
Registered: January 2017
Junior Member
I try to migrate my project from Java 6 + WebLogic 12.1.1 + EclipseLink 2.5.0 to Java 8 + WebLogic 12.1.3 + EclipseLink 2.6.4.

In all my EclipseLink entities I have @Id, @Temporal and @Column annotations for getters and not for fields. But when I deploy my app to the newer WebLogic it fails with errors like this
Quote:

org.eclipse.persistence.exceptions.ValidationException Exception Description: Entity class [class com.example.MyEntity] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass

How can I tell EclipseLink to look for this annotation above getId() method, and not above private id field?

Maybe I should ask admins to tune WebLogic in some way?


an example of entity
@Entity
@ReadOnly
@Table(name="CONTRACT_OPTION", schema="SCH")

public class ContractOption implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long contractOptionId;
    private String contractOptionName;
    private BigDecimal sortOrder;
    private Date date;
    public ContractOption() {}


    @Id
    @Column(name="CONTRACT_OPTION_ID")
    public Long getContractOptionId() {
        return this.contractOptionId;
    }

    public void setContractOptionId(Long contractOptionId) {
        this.contractOptionId = contractOptionId;
    }


    @Column(name="CONTRACT_OPTION_NAME")
    public String getContractOptionName() {
        return this.contractOptionName;
    }

    public void setContractOptionName(String contractOptionName) {
        this.contractOptionName = contractOptionName;
    }


    @Column(name="SORT_ORDER")
    public BigDecimal getSortOrder() {
        return this.sortOrder;
    }

    public void setSortOrder(BigDecimal sortOrder) {
        this.sortOrder = sortOrder;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="DATE")
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @Override
    public String toString() {
        return getContractOptionName();
    }
}
Re: Trouble with getter annotations in entities [message #1751588 is a reply to message #1751436] Wed, 11 January 2017 17:11 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1275
Registered: July 2009
Senior Member
Try specifying the @Access(AccessType.PROPERTY) on the entity, though I don't know what would cause the change in behavior unless you have other annotations that might cause it to use field access.
https://www.eclipse.org/eclipselink/api/2.0.2/javax/persistence/AccessType.html
Previous Topic:Issue with EclipseLink entities
Next Topic:Moxy xpath predicate not working
Goto Forum:
  


Current Time: Wed Dec 13 17:08:08 GMT 2017

Powered by FUDForum. Page generated in 0.02583 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software