LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Ebean: exception when a field that is related to another entity is null (http://www.linuxquestions.org/questions/programming-9/ebean-exception-when-a-field-that-is-related-to-another-entity-is-null-4175428071/)

eantoranz 09-19-2012 07:05 PM

Ebean: exception when a field that is related to another entity is null
 
Hi!

I have this entity where either one of two fields has to be set and they both point to a different entity.

I have both fields set as @ManyToOne and have set their @JoinColumns accordingly.

For the sake of the example, say entity A has a field that is related to entity B and another to entity C. They are supposed to be mutually exclusive, if you set b then c will be null and viceversa.

Something like:

Code:

@Entity
public class A {

    @ManyToOne
    @JoinColumn
    private B b;
    @ManyToOne
    @JoinColumn
    private C c;

}

At the moment I'm using only one of the fields so if I comment out the other unused field (and it's getter/setter) I can use the entity without a single hiccup.

However, when I uncomment it (but don't set anything on it..... or even if I set it to null) I get this exception when I try to save a new instance of A:

Code:

javax.persistence.PersistenceException: ERROR executing DML bindLog[] error[Unknown Types value.]
        at com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.execute(DmlBeanPersister.java:116)
        at com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.insert(DmlBeanPersister.java:76)
        at com.avaje.ebeaninternal.server.persist.DefaultPersistExecute.executeInsertBean(DefaultPersistExecute.java:91)
        at com.avaje.ebeaninternal.server.core.PersistRequestBean.executeNow(PersistRequestBean.java:500)
        at com.avaje.ebeaninternal.server.core.PersistRequestBean.executeOrQueue(PersistRequestBean.java:530)
        at com.avaje.ebeaninternal.server.persist.DefaultPersister.insert(DefaultPersister.java:406)
        at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveVanillaInsert(DefaultPersister.java:377)
        at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveVanillaRecurse(DefaultPersister.java:361)
        at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveRecurse(DefaultPersister.java:308)
        at com.avaje.ebeaninternal.server.persist.DefaultPersister.save(DefaultPersister.java:282)
        at com.avaje.ebeaninternal.server.core.DefaultServer.save(DefaultServer.java:1629)
        at com.avaje.ebeaninternal.server.core.DefaultServer.save(DefaultServer.java:1619)
        at com.avaje.ebean.Ebean.save(Ebean.java:526)
        at la.cps.warp.entity.AbstractEntity.save(AbstractEntity.java:71)
        at la.cps.warp.daemon.DaemonClient.processMessage(DaemonPort.java:293)
        at la.cps.warp.daemon.DaemonClient.getMessage(DaemonPort.java:186)
        at la.cps.warp.daemon.DaemonClient.run(DaemonPort.java:141)
Caused by: org.postgresql.util.PSQLException: Unknown Types value.
        at org.postgresql.jdbc2.AbstractJdbc2Statement.setNull(AbstractJdbc2Statement.java:1152)
        at org.postgresql.jdbc3.AbstractJdbc3Statement.setNull(AbstractJdbc3Statement.java:1490)
        at org.postgresql.jdbc4.AbstractJdbc4Statement.setNull(AbstractJdbc4Statement.java:81)
        at com.avaje.ebeaninternal.server.lib.sql.ExtendedPreparedStatement.setNull(ExtendedPreparedStatement.java:311)
        at com.avaje.ebeaninternal.server.type.DataBind.setNull(DataBind.java:62)
        at com.avaje.ebeaninternal.server.type.ScalarTypeUUID.bind(ScalarTypeUUID.java:70)
        at com.avaje.ebeaninternal.server.type.ScalarTypeUUID.bind(ScalarTypeUUID.java:31)
        at com.avaje.ebeaninternal.server.deploy.BeanProperty.bind(BeanProperty.java:663)
        at com.avaje.ebeaninternal.server.persist.dml.DmlHandler.bindInternal(DmlHandler.java:264)
        at com.avaje.ebeaninternal.server.persist.dml.DmlHandler.bind(DmlHandler.java:223)
        at com.avaje.ebeaninternal.server.deploy.id.ImportedIdSimple.bind(ImportedIdSimple.java:150)
        at com.avaje.ebeaninternal.server.persist.dmlbind.BindableAssocOne.dmlBind(BindableAssocOne.java:95)
        at com.avaje.ebeaninternal.server.persist.dmlbind.BindableAssocOne.dmlBind(BindableAssocOne.java:81)
        at com.avaje.ebeaninternal.server.persist.dmlbind.BindableList.dmlBind(BindableList.java:69)
        at com.avaje.ebeaninternal.server.persist.dml.InsertMeta.bind(InsertMeta.java:164)
        at com.avaje.ebeaninternal.server.persist.dml.InsertHandler.bind(InsertHandler.java:133)
        at com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.execute(DmlBeanPersister.java:98)
        ... 16 more

Why is that? Keep in mind (just in case) that the @Id field for B and C is a UUID field (don't know how this affects it but there you go).

Thanks in advance.


All times are GMT -5. The time now is 06:59 AM.