Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink 2.3: One-to-one association(Internal query formation isn't proper)
EclipseLink 2.3: One-to-one association [message #1386755] Fri, 20 June 2014 07:00 Go to next message
Subhadip Chatterjee is currently offline Subhadip ChatterjeeFriend
Messages: 12
Registered: December 2013
Junior Member
Hello,
I am getting an error when I fetch an associated object (1-1), using valueHolder.getValue(). Here is the relational structure:

#"Order-Transfer" model has 1-1 relation with "Order-transfer-accepted-event" model

#In the java bean, OrderTransfer class has the attribute "orderTransferAcceptedEventHolder", of type ValueHolderInterface.

#"Order-transfer-accepted-event" is actually a subclass of "TransferEvent" that is mapped to [Order_Event_Deatil] table in database.

#"TransferEvent" is a subclass of "OrderEvent" class; "OrderEvent" is mapped to [Order_Event] table.

#When I call {orderTranfer}.getOrderTransferAcceptedEventHolder().getValue() -> it internally creates a prepared statement "select from order_event t0, order_event_detail t1 where t1.order_event_no = ?"

Now this statement is missing "select * from..." syntax and hence I am getting

Error message - Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00936: missing expression

Please suggest.
Re: EclipseLink 2.3: One-to-one association [message #1386814 is a reply to message #1386755] Fri, 20 June 2014 17:52 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
The query used inside the valueholder is somehow incomplete. Looking at your prior questions involving migrating older TopLink projects, this issue could have a number of causes such as a migration or other issue. If it is urgent, I'd suggest filing an Oracle support case who can look at the original and migrated projects and check for conversion issues. Otherwise, is this a new mapping or one that worked in a prior version? Do other valueholder relationships work for you, or is this issue appearing on a few? It would be good to provide the mapping configuration, as well as the query used to bring in the OrderTransfer instance who's valueholder is having the issue. Also, how are you adding the mapping into the session, and when?
Re: EclipseLink 2.3: One-to-one association [message #1386836 is a reply to message #1386814] Sat, 21 June 2014 10:15 Go to previous messageGo to next message
Subhadip Chatterjee is currently offline Subhadip ChatterjeeFriend
Messages: 12
Registered: December 2013
Junior Member
Hello Chris,
Yes this is part of the newly created EclipseLink mappings. As part of the migration, we actually created all new set of configurations, referring the old TopLink config xmls, using EclipseLink workbench.

The 1-1 mapping works in many other cases, so I am unable to comprehend the reason in this case. Have you got any clue?
Re: EclipseLink 2.3: One-to-one association [message #1387043 is a reply to message #1386836] Mon, 23 June 2014 16:39 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
No clue at this point, especially that your workaround to another issue was to call initialize on something directly, something that should be initialized when the session is logged in. Can you post the problem mapping and include the query bringing in the OrderTransfer as this might also help shed light on what is happening.
Re: EclipseLink 2.3: One-to-one association [message #1387505 is a reply to message #1387043] Wed, 25 June 2014 07:25 Go to previous message
Subhadip Chatterjee is currently offline Subhadip ChatterjeeFriend
Messages: 12
Registered: December 2013
Junior Member
Hello,
Please find the code snippet which is used to initialize:

Iterator<?> descItr = session.getDescriptors().values().iterator();
while (descI.hasNext()) {
	ClassDescriptor descriptor = (ClassDescriptor) descItr.next();
	...
	for (Iterator<?> mapItr = descriptor.getMappings().iterator(); mapItr.hasNext();) {
		DatabaseMapping mapping = (DatabaseMapping) mapItr.next();
		...
		if (mapping.isForeignReferenceMapping()) {
			...
			if mapping-field-is-of-ValueHolder-type { // 1-1 mapping
				ContainerIndirectionPolicy policy = new ContainerIndirectionPolicy();
				policy.setMapping(mapping);
				policy.setContainerClass(CONTAINER_CLASS);
				policy.initialize(); // To set the container-constructor						
				((ForeignReferenceMapping) mapping).setIndirectionPolicy(policy);
			}
		}
	}
}


Now the {policy.initialize()} had to be called to fix the mapping issues, during code migration.

Now the OrderTransfer mapping is:
<class-mapping-descriptor xsi:type="relational-class-mapping-descriptor">
	<class>business.trade.model.OrderTransfer</class>
	<alias>OrderTransfer</alias>
	<primary-key>
	<field table="ORDER_TRANSFER" name="ORDER_TRANSFER_ID" xsi:type="column"/>
	</primary-key>
	...
	<attribute-mapping xsi:type="one-to-one-mapping">
	  <attribute-name>orderEventAcceptedHolder</attribute-name>
	  <get-method>getOrderEventAcceptedHolder</get-method>
	  <set-method>setOrderEventAcceptedHolder</set-method>
	  <reference-class>business.order.model.event.TransferEvent</reference-class>
	  <foreign-key>
		<field-reference>
		  <source-field table="ORDER_TRANSFER" name="ORDER_EVENT_NO_ACCEPTED" xsi:type="column"/>
		  <target-field table="ORDER_EVENT_DETAIL" name="ORDER_EVENT_NO" xsi:type="column"/>
		</field-reference>
	  </foreign-key>
	  <foreign-key-fields>
		<field table="ORDER_TRANSFER" name="ORDER_EVENT_NO_ACCEPTED" xsi:type="column"/>
	  </foreign-key-fields>
	  <selection-query xsi:type="read-object-query"/>
	</attribute-mapping>
	...
</class-mapping>


And the TransferEvent mapping, is
<class-mapping-descriptor xsi:type="relational-class-mapping-descriptor">
	<class>business.order.model.event.TransferEvent</class>
	<alias>TransferEvent</alias>
	<primary-key>
		<field table="ORDER_EVENT_DETAIL" name="ORDER_EVENT_NO" xsi:type="column"/>
	</primary-key>
	...
	<attribute-mapping xsi:type="one-to-one-mapping">
		<attribute-name>orderTransferAcceptedHolder</attribute-name>
		<get-method>getOrderTransferAcceptedHolder</get-method>
		<set-method>setOrderTransferAcceptedHolder</set-method>
		<reference-class>business.trade.model.OrderTransfer</reference-class>
		<foreign-key>
			<field-reference>
				<source-field table="ORDER_EVENT_DETAIL" name="ORDER_EVENT_NO" xsi:type="column"/>
				<target-field table="ORDER_TRANSFER" name="ORDER_EVENT_NO_ACCEPTED" xsi:type="column"/>
			</field-reference>
		</foreign-key>
		<selection-query xsi:type="read-object-query"/>
	</attribute-mapping>
	...
</class-mapping-descriptor>


The issue comes when, this code is invoked: orderTransfer.getOrderEventAcceptedHolder().getValue().

This is query generated, which lacks [SELECT *]
"select from order_event t0, order_event_detail t1 where t1.order_event_no = ?"

Hope you get the hint from this.
Previous Topic:OneToOne Mapping Exception
Next Topic:Embeded Object JPQL query not working
Goto Forum:
  


Current Time: Tue Mar 19 02:54:33 GMT 2024

Powered by FUDForum. Page generated in 0.01701 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top