openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeremy Bauer (JIRA)" <>
Subject [jira] [Commented] (OPENJPA-1569) @Strategy triggers an InvalidStateException for fields which are declared as Java interfaces
Date Wed, 10 Apr 2013 19:47:16 GMT


Jeremy Bauer commented on OPENJPA-1569:

Change for 1.2.x was committed under revision r1053401.  The commit was mis-tagged to OPENJPA-1596.
> @Strategy triggers an InvalidStateException for fields which are declared as Java interfaces
> --------------------------------------------------------------------------------------------
>                 Key: OPENJPA-1569
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 1.2.2, 2.0.0-beta2
>         Environment: MacOS X, Spring 3.0, Maven
>            Reporter: Jerry Carter
>            Assignee: Donald Woods
>            Priority: Minor
>             Fix For: 1.2.3, 2.0.0
>         Attachments: OPENJPA-1569-1.2.x.patch, patch.txt
> The @Strategy annotation works fine for classes but does not work if the field is a Java
interface.  Consider:
> 	@Persistent
> 	@Strategy("SimpleHandler")
> 	@Column(name="address_packed")
> 	private BaseAddress address;
> 	public BaseAddress getAddress() { return address; }
> 	public void setAddress(BaseAddress address) { this.address = address; }
> This works perfectly if BaseAddress is defined as a class but results in an InvalidStateException
if it is an interface:
> <openjpa-2.0.0-beta2-rexported fatal user error> org.apache.openjpa.persistence.InvalidStateException:
Encountered unmanaged object in persistent field "com.example.SimpleEntity.address" during
flush.  However, this field does not allow cascade persist. Set the cascade attribute for
this field to CascadeType.PERSIST or CascadeType.ALL (JPA annotations) or "persist" or "all"
(JPA orm.xml), or enable cascade-persist globally, or manually persist the related field value
prior to flushing. You cannot flush unmanaged objects or graphs that have persistent associations
to unmanaged objects.
> FailedObject: com.example.USAddress@4e0a39de
> 	at org.apache.openjpa.kernel.SingleFieldManager.preFlushPC(
> 	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(
> 	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(
> 	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(
> 	at org.apache.openjpa.kernel.StateManagerImpl.preFlush(
> 	at org.apache.openjpa.kernel.PNewState.beforeFlush(
> 	at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(
> 	at org.apache.openjpa.kernel.BrokerImpl.flush(
> 	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(
> 	at org.apache.openjpa.kernel.BrokerImpl.flush(
> 	at org.apache.openjpa.kernel.DelegatingBroker.flush(
> 	at org.apache.openjpa.persistence.EntityManagerImpl.flush(
> 	... etc ...
> Here com.example.USAddress is a class which implements the BaseAddress interface.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message