Bug 103968 - Persistence shortens table names to keywords
Persistence shortens table names to keywords
Status: CLOSED RAWHIDE
Product: Red Hat Web Application Framework
Classification: Retired
Component: persistence (Show other bugs)
6.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Archit Shah
Jon Orris
:
Depends On:
Blocks: 100952
  Show dependency treegraph
 
Reported: 2003-09-08 11:26 EDT by Stanislav Freidin
Modified: 2007-04-18 12:57 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-10-07 18:08:54 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Stanislav Freidin 2003-09-08 11:26:53 EDT
From Bugzilla Helper:
User-Agent: Opera/7.11 (Windows NT 5.1; U)  [en]

Description of problem:
Persistence automaticaly shortens table names in its deletion SQL when it 
generates SQL from PDL files. Unfortunately, it sometimes happens to produce a 
keyword as the result. For example, if you create a table named "omt_nights", 
you'll get the following error:

select on.nights_id as c_1,
       ci.language as c_2,
       ci.version as c_3,
       ci.name as c_4,
       ci.ancestors as c_5
from omt_nights on
     join cms_items ci on ci.item_id = on.nights_id
where ? = on.nights_id
java.sql.SQLException: ERROR:  parser: parse error at or near "on"

	at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:142)
	at org.postgresql.jdbc1.AbstractJdbc1Connection.
ExecSQL(AbstractJdbc1Connection.java:505)
	at org.postgresql.jdbc1.AbstractJdbc1Statement.
execute(AbstractJdbc1Statement.java:320)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.
execute(AbstractJdbc2Statement.java:48)
	at com.arsdigita.db.PreparedStatement.doExecute(PreparedStatement.java:213)
	at com.arsdigita.db.PreparedStatement.execute(PreparedStatement.java:184)
	at com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.
java:442)
	at com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.
java:394)
	at com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.
java:227)
	at com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.
java:218)
	at com.redhat.persistence.Session.fetchPropertyData(Session.java:800)
	at com.redhat.persistence.Session$1.onRole(Session.java:115)
	at com.redhat.persistence.metadata.Role.dispatch(Role.java:92)
	at com.redhat.persistence.Session.get(Session.java:113)
	at com.redhat.persistence.Expander.onDelete(Expander.java:140)
	at com.redhat.persistence.DeleteEvent.dispatch(DeleteEvent.java:39)
	at com.redhat.persistence.Expander.expand(Expander.java:62)
	at com.redhat.persistence.Session.delete(Session.java:217)
	at com.arsdigita.persistence.DataObjectImpl.delete(DataObjectImpl.java:355)
	at com.arsdigita.domain.DomainObject.delete(DomainObject.java:324)
	at com.starwood.offers.test.NightsTest.testDelete(NightsTest.java:78)

This happens because *o*mt_*n*ights gets shortened to "on". The same thing will 
happen with something like "omt_residences", which gets shortened to "or". I 
think this only occurs when you try to delete a domain object; creation, loading 
and updates seem to be unaffected.


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Create a domain object backed by an "omt_nights" table
2. Instantiate a new object
3. Try to delete it
    

Actual Results:  Got a parse exception:

select on.nights_id as c_1,
       ci.language as c_2,
       ci.version as c_3,
       ci.name as c_4,
       ci.ancestors as c_5
from omt_nights on
     join cms_items ci on ci.item_id = on.nights_id
where ? = on.nights_id
java.sql.SQLException: ERROR:  parser: parse error at or near "on"

	at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:142)
	at org.postgresql.jdbc1.AbstractJdbc1Connection.
ExecSQL(AbstractJdbc1Connection.java:505)
	at org.postgresql.jdbc1.AbstractJdbc1Statement.
execute(AbstractJdbc1Statement.java:320)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.
execute(AbstractJdbc2Statement.java:48)
	at com.arsdigita.db.PreparedStatement.doExecute(PreparedStatement.java:213)
	at com.arsdigita.db.PreparedStatement.execute(PreparedStatement.java:184)
	at com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.
java:442)
	at com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.
java:394)
	at com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.
java:227)
	at com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.
java:218)
	at com.redhat.persistence.Session.fetchPropertyData(Session.java:800)
	at com.redhat.persistence.Session$1.onRole(Session.java:115)
	at com.redhat.persistence.metadata.Role.dispatch(Role.java:92)
	at com.redhat.persistence.Session.get(Session.java:113)
	at com.redhat.persistence.Expander.onDelete(Expander.java:140)
	at com.redhat.persistence.DeleteEvent.dispatch(DeleteEvent.java:39)
	at com.redhat.persistence.Expander.expand(Expander.java:62)
	at com.redhat.persistence.Session.delete(Session.java:217)
	at com.arsdigita.persistence.DataObjectImpl.delete(DataObjectImpl.java:355)
	at com.arsdigita.domain.DomainObject.delete(DomainObject.java:324)
	at com.starwood.offers.test.NightsTest.testDelete(NightsTest.java:78)

Expected Results:  Object gets deleted

Additional info:
Comment 1 Mike Bonnet 2003-09-08 11:35:50 EDT
The same thing happens in Oracle.  Here's the stack trace (from within a JUnit
test):

2003-09-08 09:49:26,194 [ main] ERROR rdbms.RDBMSEngine - select
on.notification_id as c_1,
       ci.language as c_2,
       ci.version as c_3,
       ci.name as c_4,
       ci.ancestors as c_5
from omt_notifications on,
     cms_items ci
where ci.item_id = on.notification_id and ? = on.notification_id
java.sql.SQLException: ORA-00936: missing expression
                                                                               
                                                                               
      
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
        at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:2321)
        at oracle.jdbc.oci8.OCIDBAccess.parseExecuteDescribe(OCIDBAccess.java:1255)
        at
oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2391)
        at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
        at
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
        at
oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:656)
        at com.arsdigita.db.PreparedStatement.doExecute(PreparedStatement.java:213)
        at com.arsdigita.db.PreparedStatement.execute(PreparedStatement.java:184)
        at
com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.java:442)
        at
com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.java:394)
        at
com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.java:227)
        at
com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.java:218)
        at com.redhat.persistence.Session.fetchPropertyData(Session.java:800)
        at com.redhat.persistence.Session$1.onRole(Session.java:115)
        at com.redhat.persistence.metadata.Role.dispatch(Role.java:92)
        at com.redhat.persistence.Session.get(Session.java:113)
        at com.redhat.persistence.Expander.onDelete(Expander.java:140)
        at com.redhat.persistence.DeleteEvent.dispatch(DeleteEvent.java:39)
        at com.redhat.persistence.Expander.expand(Expander.java:62)
        at com.redhat.persistence.Session.delete(Session.java:217)
        at com.arsdigita.persistence.DataObjectImpl.delete(DataObjectImpl.java:355)
        at com.arsdigita.domain.DomainObject.delete(DomainObject.java:324)
        at
com.starwood.offers.test.NotificationTest.testDelete(NotificationTest.java:89)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at
com.arsdigita.tools.junit.framework.BaseTestCase.runBare(BaseTestCase.java:47)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at
com.arsdigita.tools.junit.extensions.BaseTestSetup$1.protect(BaseTestSetup.java:60)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at
com.arsdigita.tools.junit.extensions.BaseTestSetup.run(BaseTestSetup.java:64)
        at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325)
        at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:536)
Comment 2 Archit Shah 2003-09-08 23:55:12 EDT
fixed on tip (35756, 35766) and branch (35771)

Note You need to log in before you can comment on or make changes to this bug.