[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Exception on using VariableOneToOneannotation
|
Hello Chris,
Even after removing 'foreignId' attribute from the 'SourceEntity' still
getting the exception saying 'Only one may be defined as writable, all
others must be specified read-only'. I have a doubt is it because of
'setForeignQueryKeyName' in SourceCustomizer class using twice to set
the foreign_id to the primary key of TargetTable1 and TargetTable2.
Thanks,
Kiran
-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx
[mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Christopher
Delahunt
Sent: 26 November 2010 13:19
To: EclipseLink User Discussions
Subject: Re: [eclipselink-users] Exception on using
VariableOneToOneannotation
Hello Kiran,
Yes, as the exception states, you have the "SourceTable.FORIENG_ID"
mapped twice - the first being the foreignId mapping, and the second in
the foreignEntity mapping.
Only 1 can be writable; the others need to be set to read-only (or
insertable+updatable =false ). Otherwise, should they ever be set
differently, there is no way to tell which one
should be written to the database.
Best Regards,
Chris
On 26/11/2010 5:17 AM, Kiran Kumar Gubbi wrote:
> Hi,
>
> While on start of the application server I am getting the eclispe link
> exception saying 'Only one may be defined as writable, all others must
be
> specified read-only.'. My table and the code detail is given below.
>
> SourceTable - ID, FOREING_CLASS_TYPE , FORIENG_ID
>
> TargetTable1 - T1_ID
> TargetTable2 - T2_ID
>
> The source table FORIENG_ID is foreing key to TagergetTable1.T1_ID and
> TargetTable2.T2_ID.
>
>
> My DescriptorCustomizer detail is
>
> public class SourceCustomizer implements DescriptorCustomizer
> {
> public void customize( final ClassDescriptor descriptor )
> {
> VariableOneToOneMapping variableOneToOneMapping = new
> VariableOneToOneMapping();
> variableOneToOneMapping.setAttributeName( "foreignEntity" );
> variableOneToOneMapping.setReferenceClass(
EntityInterface.class );
> variableOneToOneMapping.setForeignQueryKeyName(
> "SourceTable.FORIENG_ID", "TargetTable1.T1_ID"
);
>
> variableOneToOneMapping.setForeignQueryKeyName(
> "SourceTable.FORIENG_ID", "TargetTable2.T2_ID"
);
>
> variableOneToOneMapping.setTypeFieldName( "SourceTable
> .FOREING_CLASS_TYPE" );
>
> // configure class indicators
> variableOneToOneMapping.addClassIndicator(
TargetTable1.class,
> "TargetTable1" );
> variableOneToOneMapping.addClassIndicator( TargetTable2
.class,
> "TargetTable2" );
>
> variableOneToOneMapping.dontUseIndirection();
> variableOneToOneMapping.privateOwnedRelationship();
>
> // add mapping to descriptor
> descriptor.addMapping( variableOneToOneMapping );
> }
> }
>
> My entity has the VariableOntoOne mapping like the one mention below.
>
>
> @Entity
> @Table( name = "SourceTable" )
> @Customizer( SourceCustomizer.class )
> public class SourceTable
> {
>
> @VariableOneToOne()
> private EntityInterface foreignEntity;
>
> @Column( name = "FORIENG_ID", nullable = false )
> private Integer foreignId;
>
> }
>
> is there anything I am missing in this ?
>
> Thanks,
> Kiran
>
>
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users