java - Strange issue while configuring ID types for Embeddable class in EclipseLink-2.5.2 -
in current implementation have separate entity classes each db table. using jpa along eclipselink-2.5.2. working fine me @ point when data huge, lags. that's why decided start using @embedded, @embeddable , @embeddedid. while doing getting error strange me. here full stacktrace posted: https://gist.githubusercontent.com/tjdudhatra/b955812e0d1a71cf97f1/raw/11ea458869e24baae744530417ac99bc877ed514/gistfile1.txt
being specific, let me give exact scenario in case getting exception. consider code block has 3 class. 1 annotated @entity , other twos annotated @embeddable. know in 1 class cannot define @id , @embeddedid , have not done that, while deploying server, getting exception says that:
[class org.apache.{someclass}] has both @embdeddedid (on attribute [id]) , @id (on attribute []. both id types cannot specified on same entity.
@entity @table(name="user") public class user { @id public long id; @column(name="usercode") public string usercode; @elementcollection @collectiontable(name = "address", joincolumns = @joincolumn(name = "user_id")) public list<address> addresslist; .... } @embeddable public class address { @embeddedid @column(name = "id") public long id; @column(name="userid") public long userid; @column(name="address-line-1") public string addressline1; @column(name="address-line-2") public string addressline2; @elementcollection @collectiontable(name = "phone", joincolumns = @joincolumn(name = "user_id")) protected list<phone> phonelist; .... } @embeddable public class phone { @embeddedid @column(name = "id") public long id; @column(name="contact_no") public string contactno; @column(name="country_code") public int countrycode; @column(name="address_id") public int addressid; .... }
please let me know if more details required , kind of much appreciated.
thanks,
a class annotated @embeddable
must not contain @embeddedid
.
@embeddedid
annotate field of type @embeddable
class in class , mark primary key.
example :
@entity public class project { @embeddedid projectid id; ... } @embeddable class projectid { int departmentid; long projectid; ... }
edit : in case, don't think want phone
, nor address
@embeddable
. mark them regular @entity
.
Comments
Post a Comment