geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "A.L." <urkb1...@bk.ru>
Subject Re: A.L. CMR Question
Date Wed, 07 Nov 2007 17:44:47 GMT

Hi Mark,

It was CMR but I have resolved it per finder functions.
(CMR was not worked at all because foreign key is a part of primary key)

I'm using Geronimo 1.1.1. AS with Tomcat.
Databases Oracle 10g, Oracle XE, Oracle 8.1.7
My application consists of 5 modules each of them is a EAR.

The problem appears in main module depending on server start ("lucky" or
"unlucky" :-)))
If "unlucky" it can be sometimes solved by restart of Geronimo AS.
The problem appearence is independent of database version.

I have table ITEMS and dependent table ITEM_FIELDS (1:n relation) 

ITEMS
************
CREATE TABLE "ITEMS" (
		"ID" NUMBER(10 , 0) NOT NULL,
		"TIMESTAMP" DATE)

ALTER TABLE "ITEMS" ADD CONSTRAINT "PK1" PRIMARY KEY (ID)
*************

ITEM_FIELDS
***************
CREATE TABLE "ITEM_FIELDS" (
		"IT_ID" NUMBER(10 , 0) NOT NULL,
		"FIELD_ID" VARCHAR2(128) NOT NULL,
		"FIELD_NAME" VARCHAR2(128) NOT NULL)

ALTER TABLE "ITEM_FIELDS" ADD CONSTRAINT "PK53" PRIMARY KEY (IT_ID,
FIELD_ID)

ALTER TABLE "ITEM_FIELDS" ADD CONSTRAINT "FK_IT_FIELDS_53" FOREIGN KEY
(IT_ID)
	REFERENCES "ITEMS" (ID)
	ON DELETE CASCADE
	ON UPDATE CASCADE
*************

...
Caused by: org.tranql.ql.QueryException: Error executing statement: INSERT
INTO ITEM_FIELDS (IT_ID, FIELD_ID, FIELD_NAME) VALUES (?, ?, ?)
	at org.tranql.sql.jdbc.JDBCUpdateCommand.execute(JDBCUpdateCommand.java:69)
	at
org.tranql.cache.EnforceRelationshipsFlushStrategy$UpdateCommandInfo.execute(EnforceRelationshipsFlushStrategy.java:105)
	at
org.tranql.cache.EnforceRelationshipsFlushStrategy.execute(EnforceRelationshipsFlushStrategy.java:93)
	at
org.tranql.cache.EnforceRelationshipsFlushStrategy.flush(EnforceRelationshipsFlushStrategy.java:83)
	at org.tranql.intertxcache.InTxCacheTracker.flush(InTxCacheTracker.java:40)
	at org.tranql.cache.InTxCache.flush(InTxCache.java:86)
	at org.openejb.entity.cmp.CMPFinder.execute(CMPFinder.java:86)
	at
org.openejb.entity.cmp.CollectionValuedFinder.execute(CollectionValuedFinder.java:81)
	... 91 more

Caused by: java.sql.SQLException: ORA-02291: Integrit├Ąts-Constraint
(FK_IT_FIELDS_53) integrity constraint constraint name violated - parent key
not found
	at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
	at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
	at
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
	at
oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
	at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
	at
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
	at
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
	at
org.tranql.connector.jdbc.PreparedStatementHandle.executeUpdate(PreparedStatementHandle.java:103)
	at org.tranql.sql.jdbc.JDBCUpdateCommand.execute(JDBCUpdateCommand.java:67)
	... 98 more
...

Item creation is implemented like:

	public java.lang.Long ejbCreate(Date _timestamp, ArrayList _fields,
ItemFieldLocalHome _fieldsLHome) throws CreateException
	{
		try
		{
...
			this.setPTimestamp(_timestamp);
			this.setId(extractID());
...
		}
		catch(Exception e)
		{
			myContext.setRollbackOnly();
			throw new CreateException("");
		}
		return null;
	}
	
	public void ejbPostCreate(Date _timestamp, ArrayList
_fields,ItemFieldLocalHome _fieldsLHome)
	{
		try
		{
			Long itemID=(Long)myContext.getPrimaryKey();
			for(int i=0; i<_fields.size();i++)
			{
				ItemFieldLocal fieldRef=_fieldsLHome.create(
					itemID,extractFID(_fields),extractFName(_fields));
			}
		}
		catch(Exception e)
		{
			myContext.setRollbackOnly();
			throw new EJBException(e);
		}
	}


<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.1"
xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"
application-name="IManager">
  <sys:environment>
    <sys:moduleId>
      <sys:groupId>X</sys:groupId>
      <sys:artifactId>IManager</sys:artifactId>
      <sys:version>1.0</sys:version>
      <sys:type>car</sys:type>
    </sys:moduleId>
  	<sys:dependencies>  
...
		<sys:dependency>
            		<sys:groupId>console.dbpool</sys:groupId>
            		<sys:artifactId>oracle10g_xe</sys:artifactId>
        	</sys:dependency>
		<sys:dependency>
      			<sys:artifactId>sharedlib</sys:artifactId>
		</sys:dependency>
  	</sys:dependencies>  
  </sys:environment>
  <module>
    <ejb>x.jar</ejb>
    <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
    	<cmp-connection-factory>
		<resource-link>oracle10g_xe</resource-link>
	</cmp-connection-factory>
	<enforce-foreign-key-constraints />
   	<enterprise-beans>
   	  	<session>
			<ejb-name>Fasade</ejb-name>
			<jndi-name>Fasade</jndi-name>
   	  	</session>
...
      		<entity>
         		<ejb-name>ItemField</ejb-name>
           		<local-jndi-name>ItemField</local-jndi-name>
           		<table-name>ITEM_FIELDS</table-name>
         		<cmp-field-mapping>
            			<cmp-field-name>id</cmp-field-name>
                		<table-column>IT_ID</table-column>
         		</cmp-field-mapping>
         		<cmp-field-mapping>
            			<cmp-field-name>fieldID</cmp-field-name>
                		<table-column>FIELD_ID</table-column>
         		</cmp-field-mapping>
         		<cmp-field-mapping>
            			<cmp-field-name>fieldName</cmp-field-name>
                		<table-column>FIELD_NAME</table-column>
         		</cmp-field-mapping>
      		</entity>
      		<entity>
         		<ejb-name>Item</ejb-name>
           		<local-jndi-name>Item</local-jndi-name>
           		<table-name>ITEM</table-name>
         		<cmp-field-mapping>
            			<cmp-field-name>id</cmp-field-name>
                		<table-column>ID</table-column>
         		</cmp-field-mapping>
         		<cmp-field-mapping>
            			<cmp-field-name>pTimestamp</cmp-field-name>
                		<table-column>P_TIMESTAMP</table-column>
         		</cmp-field-mapping>
      		</entity>
...
   	</enterprise-beans>
    </openejb-jar>
  </module>
</application>

Names and code are slightly modified.

Regards,
Al.
-- 
View this message in context: http://www.nabble.com/A.L.-CMR-Question-tf4765450s134.html#a13632131
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message