jpa - EclipseLink MongoDB @ManyToOne classCastException on very simple example -
jpa - EclipseLink MongoDB @ManyToOne classCastException on very simple example -
i trying create eclipselink (2.4.1) on mongodb works expected when having relations. ...
i've got entity:
@entity @nosql(datatype="account", dataformat=dataformattype.mapped) // datatype -> collectionname, mapped -> because object transformed map in mongodb @table(uniqueconstraints = @uniqueconstraint(columnnames = "email")) public class business relationship extends jpamongobaseentity { @id @field(name="_id") @generatedvalue private string id; @override public string getid() { homecoming id;}; public void setid(string id) { this.id = id;}; // must unique (id fonc) @notnull @size(min = 1, max = 256) @email private string email; ...
and :
@entity @nosql(datatype="invoice", dataformat=dataformattype.mapped) // datatype -> collectionname, mapped -> because object transformed map in mongodb @table(uniqueconstraints = @uniqueconstraint(columnnames = "label")) public class invoice extends jpamongobaseentity { @id @field(name="_id") @generatedvalue private string id; ... // relations @manytoone private business relationship account;
i seek invoice having account.id = parameter. request :
typedquery<invoice> q = em.createquery("select invoice bring together i.account a.id=:accountid", invoice.class); q.setparameter("accountid", accountid); list<invoice> res = q.getresultlist();
and result same :
internal exception: java.lang.classcastexception: org.eclipse.persistence.eis.mappings.eisonetoonemapping cannot cast org.eclipse.persistence.mappings.onetoonemapping query: readallquery(referenceclass=invoice jpql="select invoice bring together i.account a.id=:accountid")
i've tried many thing (@joinfield, @onetoone, ...) run exception.
any help apprieciated.
according http://wiki.eclipse.org/eclipselink/examples/jpa/nosql#step_6_:_querying joins not supported.
you might seek mapping foreign key read-only basic mapping , accessing in query directly. or adding query key fk field described here http://wiki.eclipse.org/eclipselink/userguide/jpa/basic_jpa_development/querying/query_keys
best regards, chris
mongodb jpa eclipselink
Comments
Post a Comment