You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by jr...@apache.org on 2009/10/20 18:31:40 UTC
svn commit: r827727 [2/2] - in /openjpa/trunk:
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/
openjpa-kernel/src/main/java/or...
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdResultSetAnnotations.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdResultSetAnnotations.java?rev=827727&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdResultSetAnnotations.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdResultSetAnnotations.java Tue Oct 20 16:31:39 2009
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.delimited.identifiers;
+
+import java.util.List;
+
+import javax.persistence.Query;
+
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+
+public class TestDelimIdResultSetAnnotations
+ extends SQLListenerTestCase {
+ OpenJPAEntityManager em;
+ int id = 0;
+ Car car;
+ Pontiac pontiac;
+ Chevrolet chevrolet;
+ Car2 car2;
+ Pontiac2 pontiac2;
+ Chevrolet2 chevrolet2;
+
+ @Override
+ public void setUp() throws Exception {
+ setSupportedDatabases(
+ org.apache.openjpa.jdbc.sql.DerbyDictionary.class,
+ org.apache.openjpa.jdbc.sql.DB2Dictionary.class);
+ if (isTestsDisabled()) {
+ return;
+ }
+
+ super.setUp(
+ org.apache.openjpa.persistence.delimited.identifiers.Car.class,
+ org.apache.openjpa.persistence.delimited.identifiers.Pontiac.class,
+ org.apache.openjpa.persistence.delimited.identifiers.Chevrolet.class,
+ org.apache.openjpa.persistence.delimited.identifiers.Car2.class,
+ org.apache.openjpa.persistence.delimited.identifiers.Pontiac2.class,
+ org.apache.openjpa.persistence.delimited.identifiers.Chevrolet2.class
+ );
+ assertNotNull(emf);
+
+ em = emf.createEntityManager();
+ assertNotNull(em);
+ }
+
+ @Override
+ protected OpenJPAEntityManagerFactorySPI createEMF(final Object... props) {
+ return createNamedEMF("delimited-identifiers", props);
+ }
+
+ private void createChevrolet(int id) {
+ chevrolet = new Chevrolet(id);
+ chevrolet.setModel("Malibu");
+ chevrolet.setColor("black");
+ chevrolet.setModelYear("2009");
+ }
+
+ private void createPontiac(int id) {
+ pontiac = new Pontiac(id);
+ pontiac.setModel("G6");
+ pontiac.setColor("red");
+ pontiac.setModelYear("2005");
+ }
+
+ public void testCreate() {
+ id++;
+ createPontiac(id);
+ id++;
+ createChevrolet(id);
+
+ em.getTransaction().begin();
+ em.persist(pontiac);
+ em.persist(chevrolet);
+ em.getTransaction().commit();
+
+ runQueries();
+ }
+
+ private void runQueries() {
+ em.clear();
+ resultSetQuery();
+ }
+
+ private void resultSetQuery() {
+ String query =
+ "SELECT c.id, c.\"car model\", c.\"car color\", " +
+ "c.\"discr col\", c.\"model year\" " +
+ "FROM \"Car\" c ";
+ Query q = em.createNativeQuery(query,"CarResultSet");
+ List<Object[]> results = (List<Object[]>)q.getResultList();
+ assertEquals(2,results.size());
+
+ for (Object[] result : results) {
+ assertEquals(2, result.length);
+ assertTrue(result[0] instanceof Car2);
+ assertTrue(result[1] instanceof String);
+ Car2 car2 = (Car2)result[0];
+ String modelYear = (String)result[1];
+ if (car2.getModel().equals("G6")) {
+ assertEquals("2005", modelYear);
+ }
+ else if (car2.getModel().equals("Malibu")) {
+ assertEquals("2009", modelYear);
+ }
+ }
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdResultSetAnnotations.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdSeqGen.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdSeqGen.java?rev=827727&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdSeqGen.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdSeqGen.java Tue Oct 20 16:31:39 2009
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.delimited.identifiers;
+
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+
+public class TestDelimIdSeqGen extends SQLListenerTestCase {
+ OpenJPAEntityManager em;
+ JDBCConfiguration conf;
+ DBDictionary dict;
+ boolean supportsNativeSequence = false;
+
+ EntityB entityB;
+
+ @Override
+ public void setUp() throws Exception {
+ setSupportedDatabases(
+ org.apache.openjpa.jdbc.sql.DerbyDictionary.class,
+ org.apache.openjpa.jdbc.sql.DB2Dictionary.class);
+ if (isTestsDisabled()) {
+ return;
+ }
+
+ super.setUp(EntityB.class, DROP_TABLES);
+ assertNotNull(emf);
+
+ conf = (JDBCConfiguration) emf.getConfiguration();
+ dict = conf.getDBDictionaryInstance();
+ supportsNativeSequence = dict.nextSequenceQuery != null;
+
+ if (supportsNativeSequence) {
+ em = emf.createEntityManager();
+ assertNotNull(em);
+ }
+ }
+
+ @Override
+ protected OpenJPAEntityManagerFactorySPI createEMF(final Object... props) {
+ return createNamedEMF("delimited-identifiers", props);
+ }
+
+ public void createEntityB() {
+ entityB = new EntityB("b name");
+ }
+
+ public void testSeqGen() {
+ if (!supportsNativeSequence) {
+ return;
+ }
+ createEntityB();
+
+ em.getTransaction().begin();
+ em.persist(entityB);
+ em.getTransaction().commit();
+
+ int genId = entityB.getId();
+ em.clear();
+ em.getTransaction().begin();
+ EntityB bA = em.find(EntityB.class, genId);
+ assertEquals("b name", bA.getName());
+ em.getTransaction().commit();
+ em.close();
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdSeqGen.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimInheritance.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimInheritance.java?rev=827727&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimInheritance.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimInheritance.java Tue Oct 20 16:31:39 2009
@@ -0,0 +1,113 @@
+package org.apache.openjpa.persistence.delimited.identifiers;
+
+import java.util.List;
+
+import javax.persistence.Query;
+
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+
+public class TestDelimInheritance extends SQLListenerTestCase {
+ OpenJPAEntityManager em;
+ int id = 0;
+ Pontiac pontiac;
+ Chevrolet chevrolet;
+
+ @Override
+ public void setUp() throws Exception {
+ setSupportedDatabases(
+ org.apache.openjpa.jdbc.sql.DerbyDictionary.class,
+ org.apache.openjpa.jdbc.sql.DB2Dictionary.class);
+ if (isTestsDisabled()) {
+ return;
+ }
+
+ super.setUp(
+ org.apache.openjpa.persistence.delimited.identifiers.Car.class,
+ org.apache.openjpa.persistence.delimited.identifiers.Pontiac.class,
+ org.apache.openjpa.persistence.delimited.identifiers.Chevrolet.class,
+ DROP_TABLES);
+ assertNotNull(emf);
+
+ em = emf.createEntityManager();
+ assertNotNull(em);
+ }
+
+ @Override
+ protected OpenJPAEntityManagerFactorySPI createEMF(final Object... props) {
+ return createNamedEMF("delimited-identifiers", props);
+ }
+
+ private void createPontiac(int id) {
+ pontiac = new Pontiac(id);
+ pontiac.setModel("G6");
+ pontiac.setColor("red");
+ }
+
+ private void createChevrolet(int id) {
+ chevrolet = new Chevrolet(id);
+ chevrolet.setModel("Malibu");
+ chevrolet.setColor("black");
+ }
+
+ public void testCreate() {
+ id++;
+ createPontiac(id);
+ id++;
+ createChevrolet(id);
+
+ em.getTransaction().begin();
+ em.persist(pontiac);
+ em.persist(chevrolet);
+ em.getTransaction().commit();
+
+ runQueries();
+ }
+
+ private void runQueries() {
+ em.clear();
+ queryChevrolet();
+ em.clear();
+ queryPontiac();
+ }
+
+ private void queryChevrolet() {
+ String query =
+ "SELECT DISTINCT c " +
+ "FROM Car c " +
+ "WHERE c.model = 'Malibu'";
+ Query q = em.createQuery(query);
+ List<Car> results = (List<Car>)q.getResultList();
+ assertEquals(1,results.size());
+ }
+
+ // Use native query
+ private void queryPontiac() {
+ String query =
+ "SELECT * " +
+ "FROM \"Car\" c " +
+ "WHERE c.\"discr col\" = 'Pontiac'";
+ Query q = em.createNativeQuery(query);
+ List<Car> results = (List<Car>)q.getResultList();
+ assertEquals(1,results.size());
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimInheritance.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimitedIdentifiers.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimitedIdentifiers.java?rev=827727&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimitedIdentifiers.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimitedIdentifiers.java Tue Oct 20 16:31:39 2009
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.delimited.identifiers;
+
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+
+public class TestDelimitedIdentifiers extends SQLListenerTestCase {
+ OpenJPAEntityManager em;
+ int id = 0;
+
+ EntityA entityA;
+
+ public void setUp() throws Exception {
+ setSupportedDatabases(
+ org.apache.openjpa.jdbc.sql.DerbyDictionary.class,
+ org.apache.openjpa.jdbc.sql.DB2Dictionary.class);
+ if (isTestsDisabled()) {
+ return;
+ }
+
+ super.setUp(EntityA.class, DROP_TABLES);
+ assertNotNull(emf);
+
+ em = emf.createEntityManager();
+ assertNotNull(em);
+ }
+
+ @Override
+ protected OpenJPAEntityManagerFactorySPI createEMF(final Object... props) {
+ return createNamedEMF("delimited-identifiers", props);
+ }
+
+ public void createEntityA(int id) {
+ entityA = new EntityA(id, "aName");
+ entityA.setSecName("sec name");
+ entityA.addCollectionSet("xxx");
+ entityA.addCollectionSet("yyy");
+ entityA.addCollectionDelimSet("aaa");
+ entityA.addCollectionDelimSet("bbb");
+ }
+
+ public void testTableName() {
+ id++;
+ createEntityA(id);
+
+ em.getTransaction().begin();
+ em.persist(entityA);
+ em.getTransaction().commit();
+
+ int genId = entityA.getId();
+ em.clear();
+ em.getTransaction().begin();
+ EntityA eA = em.find(EntityA.class, genId);
+ assertEquals("aName", eA.getName());
+
+ em.getTransaction().commit();
+ em.close();
+ }
+
+ // TODO: validate with queries
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimitedIdentifiers.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimitedJoinAnnotation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimitedJoinAnnotation.java?rev=827727&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimitedJoinAnnotation.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimitedJoinAnnotation.java Tue Oct 20 16:31:39 2009
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.delimited.identifiers;
+
+import java.util.List;
+
+import javax.persistence.Query;
+
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+
+public class TestDelimitedJoinAnnotation extends SQLListenerTestCase {
+ OpenJPAEntityManager em;
+ int id = 0;
+ EntityH entityH;
+ EntityI entityI;
+ EntityI2 entityI2;
+ EntityI3 entityI3;
+ EntityI4 entityI4;
+
+ @Override
+ public void setUp() throws Exception {
+ setSupportedDatabases(
+ org.apache.openjpa.jdbc.sql.DerbyDictionary.class,
+ org.apache.openjpa.jdbc.sql.DB2Dictionary.class);
+ if (isTestsDisabled()) {
+ return;
+ }
+
+ super.setUp(
+ org.apache.openjpa.persistence.delimited.identifiers.EntityH.class,
+ org.apache.openjpa.persistence.delimited.identifiers.EntityI.class,
+ org.apache.openjpa.persistence.delimited.identifiers.EntityI2.class,
+ org.apache.openjpa.persistence.delimited.identifiers.EntityI3.class,
+ org.apache.openjpa.persistence.delimited.identifiers.EntityI4.class,
+ DROP_TABLES);
+ assertNotNull(emf);
+
+ em = emf.createEntityManager();
+ assertNotNull(em);
+ }
+
+ @Override
+ protected OpenJPAEntityManagerFactorySPI createEMF(final Object... props) {
+ return createNamedEMF("delimited-identifiers", props);
+ }
+
+ public void createHandI(int id) {
+ entityH = new EntityH(id);
+ entityH.setName("eh");
+ entityH.setSecName("secName1");
+
+ entityI = new EntityI(id);
+ entityI.setName("ei");
+
+ entityI2 = new EntityI2(id);
+ entityI2.setName("ei2");
+
+ entityI3 = new EntityI3(id);
+ entityI3.setName("ei3");
+
+ entityI4 = new EntityI4(id);
+ entityI4.setName("ei4");
+
+ entityH.addEntityI(entityI);
+ entityI.addEntityH(entityH);
+
+ entityH.setEntityI2(entityI2);
+
+ entityH.addMapValues(entityI3, entityI4);
+ entityH.addMap2Values(entityI4, entityI3);
+
+ entityI2.setEntityI3(entityI3);
+ }
+
+ public void testCreate() {
+ id++;
+ createHandI(id);
+ // TODO: Maybe create another one.
+
+ em.getTransaction().begin();
+ em.persist(entityH);
+ em.persist(entityI);
+ em.persist(entityI2);
+ em.persist(entityI3);
+ em.persist(entityI4);
+ em.getTransaction().commit();
+
+ runQueries();
+ }
+
+ private void runQueries() {
+ em.clear();
+ queryJoinTable();
+ em.clear();
+ queryJoinColumn();
+ em.clear();
+ querySecondaryTableValue();
+ em.clear();
+ queryMapValue();
+ }
+
+ private void queryJoinTable() {
+ String query =
+ "SELECT h " +
+ "FROM EntityH h JOIN h.entityIs i " +
+ "WHERE i.name = 'ei'";
+ Query q = em.createQuery(query);
+ List<EntityH> results = (List<EntityH>)q.getResultList();
+ assertEquals(1,results.size());
+ }
+
+ private void queryJoinColumn() {
+ String query =
+ "SELECT h " +
+ "FROM EntityH h JOIN h.entityI2 i2 " +
+ "WHERE i2.name = 'ei2'";
+ Query q = em.createQuery(query);
+ List<EntityH> results = (List<EntityH>)q.getResultList();
+ assertEquals(1,results.size());
+ }
+
+ private void querySecondaryTableValue() {
+ String query =
+ "SELECT h " +
+ "FROM EntityH h " +
+ "WHERE h.secName = 'secName1'";
+ Query q = em.createQuery(query);
+ List<EntityH> results = (List<EntityH>)q.getResultList();
+ assertEquals(1,results.size());
+ }
+
+ private void queryMapValue() {
+ String query =
+ "SELECT h " +
+ "FROM EntityH h, IN(h.map2) m " +
+ "WHERE m.name = 'ei3'";
+ Query q = em.createQuery(query);
+ List<EntityH> results = (List<EntityH>)q.getResultList();
+ assertEquals(1,results.size());
+ }
+
+
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimitedJoinAnnotation.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/delimited-identifiers-orm.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/delimited-identifiers-orm.xml?rev=827727&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/delimited-identifiers-orm.xml (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/delimited-identifiers-orm.xml Tue Oct 20 16:31:39 2009
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
+ http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
+ version="2.0">
+
+ <persistence-unit-metadata>
+ <persistence-unit-defaults>
+ <delimited-identifiers/>
+ </persistence-unit-defaults>
+ </persistence-unit-metadata>
+
+</entity-mappings>
\ No newline at end of file
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/delimited-identifiers-orm.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml?rev=827727&r1=827726&r2=827727&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml Tue Oct 20 16:31:39 2009
@@ -269,5 +269,12 @@
</properties>
</persistence-unit>
+ <persistence-unit name="delimited-identifiers">
+ <mapping-file>META-INF/delimited-identifiers-orm.xml</mapping-file>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings"
+ value="buildSchema"/>
+ </properties>
+ </persistence-unit>
</persistence>
Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?rev=827727&r1=827726&r2=827727&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java Tue Oct 20 16:31:39 2009
@@ -143,6 +143,12 @@
private static final Map<Class<?>, MetaDataTag> _tags =
new HashMap<Class<?>, MetaDataTag>();
+
+ // The following is needed for input into the delimitString() method
+ protected static enum DBIdentifiers {
+ SEQUENCE_GEN_SEQ_NAME,
+ SEQUENCE_GEN_SCHEMA
+ }
static {
_tags.put(Access.class, ACCESS);
@@ -1709,10 +1715,10 @@
// create new sequence
meta = getRepository().addSequenceMetaData(name);
- String seq = gen.sequenceName();
+ String seq = delimitString(gen.sequenceName(), DBIdentifiers.SEQUENCE_GEN_SEQ_NAME);
int initial = gen.initialValue();
int allocate = gen.allocationSize();
- String schema = gen.schema();
+ String schema = delimitString(gen.schema(), DBIdentifiers.SEQUENCE_GEN_SCHEMA);
String catalog = gen.catalog();
// don't allow initial of 0 b/c looks like def value
if (initial == 0)
@@ -1898,5 +1904,9 @@
return compare;
}
}
+
+ protected String delimitString(String name, DBIdentifiers type) {
+ return name;
+ }
}
Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java?rev=827727&r1=827726&r2=827727&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java Tue Oct 20 16:31:39 2009
@@ -106,6 +106,7 @@
protected static final String ELEM_PU_DEF = "persistence-unit-defaults";
protected static final String ELEM_XML_MAP_META_COMPLETE =
"xml-mapping-metadata-complete";
+ protected static final String ELEM_DELIM_IDS = "delimited-identifiers";
private static final Map<String, Object> _elems =
new HashMap<String, Object>();
@@ -132,6 +133,7 @@
_elems.put(ELEM_PU_META, ELEM_PU_META);
_elems.put(ELEM_PU_DEF, ELEM_PU_DEF);
_elems.put(ELEM_XML_MAP_META_COMPLETE, ELEM_XML_MAP_META_COMPLETE);
+ _elems.put(ELEM_DELIM_IDS, ELEM_DELIM_IDS);
_elems.put("entity-listeners", ENTITY_LISTENERS);
_elems.put("pre-persist", PRE_PERSIST);
@@ -571,6 +573,8 @@
ret = _mode != MODE_QUERY;
else if (tag == ELEM_LISTENER)
ret = startEntityListener(attrs);
+ else if (tag == ELEM_DELIM_IDS)
+ ret = startDelimitedIdentifiers();
else if (tag == ELEM_CASCADE)
ret = isMetaDataMode();
else if (tag == ELEM_CASCADE_ALL || tag == ELEM_CASCADE_PER
@@ -2093,5 +2097,9 @@
*/
public Class<?> getParseClass() {
return _cls;
- }
+ }
+
+ protected boolean startDelimitedIdentifiers() {
+ return false;
+ }
}