views:

53

answers:

3

I created one table using Inheritance concept to sore data into google app engine datastore. It contained following 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
A: 

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

DataNucleus
A: 

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.

A: 
  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.

Pascal Thivent