java - EclipseLink entity mapping problem when using property accessor methods -


given class below know why eclipselink implementation of jpa fails map them database entities? following error returned:

entity class [class com.my.entity.y] has no primary key specified. should define either @id, @embeddedid or @idclass. if have defined pk using of these annotations make sure not have mixed access-type (both fields , properties annotated) in entity class hierarchy.

@entity @access(accesstype.property) public interface y {      void setid(long id);      @id     long getid(); }  @entity public class z implements y {      long id;      @override     public void setid(long id) {         this.id = id;     }      @override     public long getid() {         return id;     } } 

many thanks

eclipselink support querying , relationships interfaces, not in annotations.

to map interface can use sessioncustomizer.

public class mycustomizer implements sessioncustomizer {     public void customize(session session) {       relationaldescriptor descriptor = new relationaldescriptor();       descriptor.setjavainterface(y.class);       descriptor.setalias("y");       session.adddescriptor(descriptor);     } } 

mapping interface allows querying on interface returns of subclasses, , defining relationships interface.

if interface used through @variableonetoone annotation automatically mapped.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -