Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] DB-generated values as properties on JPA-entity

På fredag 16. august 2013 kl. 16:49:52, skrev Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>:
På fredag 16. august 2013 kl. 15:21:35, skrev Andrei Ilitchev <andrei.ilitchev@xxxxxxxxxx>:
Try

@ReturnInsert(returnOnly=true)

That should work on PostgreSQL, too.
 
Just what I need, thanks!
 
Hm, I get a runtime-exception when using this:
 
Exception [EclipseLink-189] (Eclipse Persistence Services - 2.5.1.v20130814-ad1d746): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: ReturningPolicy contains mapped field, [id] which requires type.
Descriptor: RelationalDescriptor(no.officenet.origo.core.domain.model.person.Person --> [DatabaseTable(onp_crm_entity), DatabaseTable(onp_crm_person)])
 
 
My mapping in @Entity Person is:
 
@Column(name = "id", nullable = false, unique = true, updatable = false, insertable = false)
@ReturnInsert(returnOnly=true)
var personId: java.lang.Long = null
 
This inherits from an AbstractEntityObject which defines @Id:
 
@Entity
@Table(name = "onp_crm_entity")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING)
@SequenceGenerator(name = "AbstractEntityObjectSEQ_STORE", sequenceName = "onp_crm_entity_id_seq", allocationSize = 1)
abstract class AbstractEntityObject(_contentType: ContentType) extends AbstractDomainObject {
//...
//...
@Id
@Column(name = "entity_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AbstractEntityObjectSEQ_STORE")
var id: java.lang.Long = null
Any hints on what's wrong?
 
without @ReturnInsert annotation the app works but the property isn't populated on persist.
 
--
Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Back to the top