openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-1682) TestSimpleXmlEntity.testId failed with invalid DB2 create table SQL statement
Date Mon, 07 Jun 2010 15:45:55 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-1682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12876282#action_12876282
] 

Pinaki Poddar commented on OPENJPA-1682:
----------------------------------------

Can an unique column be nullable? The answer seems to vary across databases.

The observed DB2 error -542 points that DB2 does not allow a unique column to be nullable.
"  column-name CANNOT BE A COLUMN OF A PRIMARY KEY, A UNIQUE CONSTRAINT, OR A PARENT KEY BECAUSE
IT CAN CONTAIN NULL VALUES
Explanation : The code is used to report that a column identified in a PRIMARY KEY, a UNIQUE
constraint clause, or a parent key (via a REFERENCES clause) is defined to allow null values."

While MySQL seems to allow a null value on a column with unique constraint.

OpenJPA currently works in a way that an unique constraint on a column *does not imply* any
nullability -- positive or negative.
Earlier (prior to revision 941362), we forced that an unique constraint on a column *does
imply* non-nullability. But OPENJPA-1387 made the point that unique constraint should not
imply non-nullable -- whch I tend to agree and hence revision 941362 removed the implication.

But as the current issue shows, we need to make this implication database dependent.  




 


> TestSimpleXmlEntity.testId failed with invalid DB2 create table SQL statement
> -----------------------------------------------------------------------------
>
>                 Key: OPENJPA-1682
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1682
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 2.1.0
>            Reporter: Albert Lee
>
> TestSimpleXmlEntity.testId starts failing with the following exception against DB2:
> TestSimpleXmlEntity.testId  View test details   (org.apache.openjpa.persistence.xml)
>     <openjpa-2.1.0-SNAPSHOT-r422266:951071 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
DB2 SQL Error: SQLCODE=-542, SQLSTATE=42831, SQLERRMC=NICKNAME_XML, DRIVER=3.50.152 {stmnt
65405926 CREATE TABLE NickNames_xml (A_ID_xml INTEGER NOT NULL, nickName_xml VARCHAR(20),
CONSTRAINT U_NCKNXML_A_ID_XML UNIQUE (A_ID_xml, nickName_xml))} [code=-542, state=42831]
>     at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:556)
>     at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:456)
>     Please wait... Show details »
>     « Hide details
>     <openjpa-2.1.0-SNAPSHOT-r422266:951071 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
DB2 SQL Error: SQLCODE=-542, SQLSTATE=42831, SQLERRMC=NICKNAME_XML, DRIVER=3.50.152 {stmnt
65405926 CREATE TABLE NickNames_xml (A_ID_xml INTEGER NOT NULL, nickName_xml VARCHAR(20),
CONSTRAINT U_NCKNXML_A_ID_XML UNIQUE (A_ID_xml, nickName_xml))} [code=-542, state=42831]
>     at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:556)
>     at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:456)
>     at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:155)
>     at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:159)
>     at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:117)
>     at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:199)
>     at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
>     at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:213)
>     at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:151)
>     at org.apache.openjpa.persistence.test.SingleEMTestCase.setUp(SingleEMTestCase.java:47)
>     at org.apache.openjpa.persistence.xml.TestSimpleXmlEntity.setUp(TestSimpleXmlEntity.java:28)
>     at junit.framework.TestCase.runBare(TestCase.java:125)
>     at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:503)
>     at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:479)
>     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 org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.run(AbstractPersistenceTestCase.java:179)
>     at junit.framework.TestSuite.runTest(TestSuite.java:208)
>     at junit.framework.TestSuite.run(TestSuite.java:203)
>     at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>     at java.lang.reflect.Method.invoke(Method.java:600)
>     at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
>     at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
>     at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
>     at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>     at java.lang.reflect.Method.invoke(Method.java:600)
>     at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
>     at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
>     Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: DB2 SQL Error: SQLCODE=-542,
SQLSTATE=42831, SQLERRMC=NICKNAME_XML, DRIVER=3.50.152 {stmnt 65405926 CREATE TABLE NickNames_xml
(A_ID_xml INTEGER NOT NULL, nickName_xml VARCHAR(20), CONSTRAINT U_NCKNXML_A_ID_XML UNIQUE
(A_ID_xml, nickName_xml))} [code=-542, state=42831]
>     at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:257)
>     at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:241)
>     at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:70)
>     at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(LoggingConnectionDecorator.java:951)
>     at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(DelegatingStatement.java:136)
>     at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1200)
>     at org.apache.openjpa.jdbc.schema.SchemaTool.createTable(SchemaTool.java:956)
>     at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:533)
>     at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:348)
>     at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:325)
>     at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:504)
>     ... 33 more
> The create table constraint  requires nickName_xml be "NOT NULL"
> Albert Lee

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message