playframework - PersistenceException: Error with [models.Task] It has not been enhanced but it's superClass -
i working 2 databases while saving data object in table getting following error:
persistenceexception: error [models.task] has not been enhanced superclass [class play.db.ebean.model] has? (you not allowed mix enhancement in single inheritance hierarchy) marker[play.db.ebean.model] classname[models.task]
i using 2 java classes 1 task.class , other userdetails.class:
task.class :
@entity @table(name="third") public class task extends model { @id @column(name="id") private int id; @column(name="name") private string username; public static finder finduser=new finder<string,task>(string.class,task.class); }
and userdetails.class :
@entity @table(name="userdetails") public class userdetail extends model{ @id @column(name="id") private int id; @column(name="username") private string username; @column(name="itemdetail") private string itemname; public static finder finduser=new finder<string,userdetail (string.class,userdetail.class); }
my application.conf file is:
db.default.driver=com.mysql.jdbc.driver db.default.url="jdbc:mysql://localhost:3306/test?characterencoding=utf-8" db.default.user=root ebean.default="models.userdetail" evolutionplugin=disabled db.secondary.driver=com.mysql.jdbc.driver db.secondary.url="jdbc:mysql://localhost:3306/secondary?characterencoding=utf-8" db.secondary.user=root ebean.secondary="models.task"
i have tried solutions stackoverflow still it's not working. of them like:
1. @mappedsuperclass 2. ebean.dafault=model.*.*
have read question?
you did not mention play version using? following configuration works me on play 2.2.3:
db.default.driver=com.mysql.jdbc.driver db.default.url="jdbc:mysql://localhost:3306/test?characterencoding=utf-8" db.default.user=xxx db.default.password="xxx" ebean.default="models.userdetail" db.secondary.driver=com.mysql.jdbc.driver db.secondary.url="jdbc:mysql://localhost:3306/secondary?characterencoding=utf-8" db.secondary.user=xxx db.secondary.password="xxx" ebean.secondary="models.task"
the following controller code saves entities (as are) 2 databases correctly:
public static result index() { userdetail userdetail = new userdetail(); userdetail.save(); task task = new task(); task.save("secondary"); }
note pass in server name save()
method models.task
. tells ebean datasource use when saving.
why entities fields private
, not public
? did leave out getters/setters brevity or there reason? ask because of this comment
Comments
Post a Comment