Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Exception when same column is used in key class(writable) and in other attribute (as readonly)

Hi,

This is migration project from hibernate to eclipselink. 
We are using same column 'name' in key class as well as attribute .One is
readable and other is writable. It works in hibernate.

Mapping is :

	<embeddable  class="entity.StandAloneEntityComponent1"  >
	    <attributes>
	        <basic name="name">
	        </basic>
	    </attributes>
	    
	</embeddable>

	<entity  class="frentity.StandAloneEntityIDClass" >
		

		<attributes>
			<id name="id" attribute-type="java.lang.String">
				<column name="entity_id" />
			</id>
			<id name="name"  >
				<column name="name" />
			</id>
		
			<embedded  name="component"
attribute-type="entity.StandAloneEntityComponent1">
				<attribute-override name="name" >
					<column name="name" insertable="false" updatable="false"/>
 				</attribute-override>
	
			</embedded>

		</attributes>
		<id-class class="entity.StandAloneEntityIDClassKey"/>
	</entity>



We are getting following exception on load


Internal Exception: java.lang.IllegalArgumentException: Can not set
java.lang.String field entity.StandAloneEntityComponent1.name to
entity.StandAloneEntityIDClassKey
Descriptor: RelationalDescriptor(entity.StandAloneEntityIDClass -->
[DatabaseTable(standalone_idclass)])
	at
org.eclipse.persistence.exceptions.DescriptorException.errorUsingPrimaryKey(DescriptorException.java:1923)
	at
org.eclipse.persistence.internal.jpa.CMP3Policy$FieldAccessor.getValue(CMP3Policy.java:663)
	at
org.eclipse.persistence.internal.jpa.CMP3Policy.createPrimaryKeyFromId(CMP3Policy.java:239)
	at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.getReference(UnitOfWorkImpl.java:5843)
	at
org.eclipse.persistence.internal.jpa.EntityManagerImpl.getReference(EntityManagerImpl.java:1316)

Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String
field entity.StandAloneEntityComponent1.name to
entity.StandAloneEntityIDClassKey
	at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
	at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
	at
sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
	at
sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
	at java.lang.reflect.Field.get(Field.java:358)
	at
org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getValueFromField(PrivilegedAccessHelper.java:381)
	at
org.eclipse.persistence.internal.jpa.CMP3Policy$FieldAccessor.getValue(CMP3Policy.java:660)
	... 29 more





--
View this message in context: http://eclipse.1072660.n5.nabble.com/Exception-when-same-column-is-used-in-key-class-writable-and-in-other-attribute-as-readonly-tp162585.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.


Back to the top