Java – generics and JSON

I'm using the play framework

model:

public class JSONContainer<T> extends Model {

    private T myT;
    private StatusMessage mySm;

    public JSONContainer(T myT,StatusMessage mySm) {
        this.myT = myT;
        this.mySm = mySm;
    }
}

then:

In the functions of controller:

JSONContainer<User> myJ = new JSONContainer(logged,sm);
renderJSON(myJ);

User is recorded and SM is statusmessage I received an error:

type:   'play.exceptions.JavaExecutionException'

If I don't use generics, it works Any ideas?

The console provides this output, where line 43 is:

JSONContainer<User> myJ = new JSONContainer(logged,sm);

Solution

Hibernate cannot map common entities

You should perform generic class abstraction and create a specific implementation (using any other possible values of user and T) This should solve the problem

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>