LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-19-2012, 07:05 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Rep: Reputation: 83
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.
 
  


Reply

Tags
ebean, java, uuid


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ebean: why is Ebean trying to do an update by doing where with all fields? eantoranz Programming 3 08-30-2012 02:33 PM
[SOLVED] Count occurrence of character in field and print in a new field Trd300 Linux - Newbie 5 03-21-2012 07:57 PM
"null pointer exception" Ubuntu vp702x dicksch Ubuntu 2 01-30-2012 07:21 PM
[SOLVED] awk: how to print a field when field position is unknown? elfoozo Programming 12 08-18-2010 03:52 AM
help createing exception class from base STL exception qwijibow Programming 4 04-20-2005 05:23 AM


All times are GMT -5. The time now is 09:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration