开发者

Inheritance concept in jpa

I created one table using Inheritance concept to sore data into google app engine datastore. It contained follow开发者_开发问答ing coding but it shows error.How to user Inheritance concept.What error in my program

Program 1:

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class calender {

    @Id
    private String EmailId;

    @Basic
    private String CalName;

    @Basic
    public void setEmailId(String emailId) {
        EmailId = emailId;    
    }

    public String getEmailId() {    
        return EmailId;    
    }

    public void setCalName(String calName) {    
        CalName = calName;    
    }

    public String getCalName() {
        return CalName;    
    }

    public calender(String EmailId, String CalName) {    
        this.EmailId = EmailId;    
        this.CalName = CalName;    
    }
}

Program 2:

@Entity
public class method extends calender {
    @Id
    private String method;

    public void setMethod(String method) {
        this.method = method;
    }

    public String getMethod() {    
        return method;    
    }

    public method(String method) {    
        this.method = method;    
    }

}

My constraint is I want output like this

Calendartable contain

Emailid 

calendarname

and method table contain

Emailid

method

How to achieve this?

It shows the following error in this line public method(String method)

java.lang.Error: Unresolved compilation problem: 

    Implicit super constructor calender() is undefined. Must explicitly invoke another constructor


  1. According to Using JPA with App Engine, the JOINED inheritance strategy is not supported.

  2. Your code doesn't compile, add a default constructor in Calendar.

  3. I don't think you should annotate the method field with @Id.


The datastore of GAE/J is not an RDBMS so consequently the only "inheritance strategy" that makes any sense is TABLE_PER_CLASS. I would expect GAE/J to throw an exception if you specify that strategy, and if it doesn't then you ought to raise an issue against them


Your error "constructor calender() is undefined" is rather straightforward. You should create constructor without parameters in calendar class (you can make it private if you don't want to use it). That's because compiler can create default constructor by himself only if there aren't another constructors in the class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜