openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schmidt <fakod...@googlemail.com>
Subject identity class IllegalArgumentException
Date Wed, 09 Jun 2010 16:23:44 GMT
Hi list,

I am using OpenJPA 2.0, Posgresql and JDBC4

and the following entity (well - its Scala ;-) @BeanProperty
translates to a private property and a setter- and getter-method):

@Entity
@Table(name = "org_struct")
@IdClass(classOf[OrganisationStructureId])
@SequenceGenerator(name = "org_struct_index_seq", sequenceName =
"org_struct_index_sequence", allocationSize = 1)
class OrganisationStructure extends MIPEntity {
  @Id
  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"org_struct_index_seq")
  @Column(name = "org_struct_ix", nullable = false, length = 20)
  @BeanProperty
  protected var ix: BigInteger = _

  @Id
  @ManyToOne(fetch = FetchType.EAGER)
  @JoinColumn(name = "org_struct_root_org_id", nullable = false,
updatable = false)
  @BeanProperty
  protected var orgStructRootOrg: Organisation = _
}


/**
 * ID Class
 */
class OrganisationStructureId {
  @BeanProperty
  var orgStructRootOrg: BigInteger = _
  @BeanProperty
  var ix: BigInteger = _

  . . .
}


Doing persist I get the following exception:

org.apache.openjpa.persistence.PersistenceException: Can not set
java.math.BigInteger field
org.pf4mip.persistence.popo.OrganisationStructureId.orgStructRootOrg
to org.pf4mip.persistence.popo.Organisation
	at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2605)
	at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2423)
	at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1069)
	at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:705)
	at org.jpaextension.manager.EntityManagerWrapper$class.persistAndFlush(EntityManagerWrapper.scala:114)
	...
Caused by: java.lang.IllegalArgumentException: Can not set
java.math.BigInteger field
org.pf4mip.persistence.popo.OrganisationStructureId.orgStructRootOrg
to org.pf4mip.persistence.popo.Organisation
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
	...
Caused by: java.lang.IllegalArgumentException: Error while setting
value org.pf4mip.persistence.popo.Organisation@30e33af5 of class
org.pf4mip.persistence.popo.Organisation on field private
java.math.BigInteger
org.pf4mip.persistence.popo.OrganisationStructureId.orgStructRootOrg
of instance org.pf4mip.persistence.popo.OrganisationStructureId@0 by
reflection.
	at org.apache.openjpa.enhance.Reflection.wrapReflectionException(Reflection.java:334)
	at org.apache.openjpa.enhance.Reflection.set(Reflection.java:540)
	... 96 more


I think OpenJPA tries to put an Organisation into the BigInt field. Any advice?

Christopher

Mime
View raw message