openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r1299276 - in /openjpa: branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/ branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/ branches/2.2.x/openjpa-persistence-jdbc/src/t...
Date Sat, 10 Mar 2012 21:26:31 GMT
Author: allee8285
Date: Sat Mar 10 21:26:31 2012
New Revision: 1299276

URL: http://svn.apache.org/viewvc?rev=1299276&view=rev
Log:
OPENJPA-2153 Mark DBCPDriverDataSource non-abstract so that DBCPDriverDataSource.class.newinstance
is used to instantiate for property configuration.

Added:
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java
  (with props)
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java
  (with props)
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java
  (with props)
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java
  (with props)
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java
  (with props)
Modified:
    openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
    openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java

Modified: openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java?rev=1299276&r1=1299275&r2=1299276&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
(original)
+++ openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
Sat Mar 10 21:26:31 2012
@@ -37,7 +37,7 @@ import org.apache.openjpa.lib.util.Close
  * as it WILL NOT fall back to non-DBCP mode if they are missing. For automatic
  * usage of Commons DBCP when available, use AutoDriverDataSource instead.
  */
-public abstract class DBCPDriverDataSource
+public class DBCPDriverDataSource
 extends SimpleDriverDataSource implements Configurable, Closeable {
 
     private static String DBCPPACKAGENAME = "org.apache.commons.dbcp";

Modified: openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java?rev=1299276&r1=1299275&r2=1299276&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
(original)
+++ openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
Sat Mar 10 21:26:31 2012
@@ -31,6 +31,7 @@ import java.util.Properties;
 import java.util.logging.Logger;
 
 import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.lib.jdbc.ConnectionDecorator;
 import org.apache.openjpa.lib.jdbc.DelegatingDataSource;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
@@ -146,8 +147,7 @@ public class SimpleDriverDataSource
         return _connectionFactoryProperties;
     }
 
-    @SuppressWarnings("unchecked")
-    public List createConnectionDecorators() {
+    public List<ConnectionDecorator> createConnectionDecorators() {
         return null;
     }
 
@@ -206,8 +206,7 @@ public class SimpleDriverDataSource
     
 
     // java.sql.Wrapper implementation (JDBC 4)
-    @SuppressWarnings("unchecked")
-    public boolean isWrapperFor(Class iface) {
+    public boolean isWrapperFor(Class<?> iface) {
         return iface.isAssignableFrom(SimpleDriverDataSource.class);
     }
 
@@ -218,9 +217,9 @@ public class SimpleDriverDataSource
         else
             return null;
     }
-    
+
     // Java 7 methods follow
-    
+
     public Logger getParentLogger() throws SQLFeatureNotSupportedException{
     	throw new SQLFeatureNotSupportedException();
     }

Added: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java?rev=1299276&view=auto
==============================================================================
--- openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java
(added)
+++ openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java
Sat Mar 10 21:26:31 2012
@@ -0,0 +1,75 @@
+/*
+ * 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.jdbc.query;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.jdbc.query.domain.DtaSrc;
+import org.apache.openjpa.persistence.jdbc.query.domain.DtaSrcField;
+import org.apache.openjpa.persistence.jdbc.query.domain.Game;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+/**
+ * Tests "openjpa.jdbc.DriverDataSource=dbcp" option.
+ *  
+ * Further details can be found in
+ * <A HREF="https://issues.apache.org/jira/browse/OPENJPA-2153">OPENJPA-2153</A>
+ * 
+ */
+public class TestNewJavaObjectQuery extends SingleEMFTestCase {   
+    public void setUp() {
+        super.setUp(CLEAR_TABLES, Game.class,
+                DtaSrc.class, DtaSrcField.class, 
+                "openjpa.jdbc.DriverDataSource", "dbcp");
+    }
+
+//	void createData() throws Exception {
+//		EntityManager em = emf.createEntityManager();
+//		em.getTransaction().begin();
+//        Class[] classes = { Game.class, IndoorGame.class, Scrabble.class,
+//				Chess.class };
+//		for (Class cls : classes) {
+//			for (int i = 1; i <= 4; i++) {
+//				Game p = (Game) cls.newInstance();
+//				p.setName(cls.getSimpleName() + "-" + i);
+//				em.persist(p);
+//			}
+//		}
+//		em.getTransaction().commit();
+//	}
+
+    public void testNewJavaObjectQueryResultList() {
+        String jpql = "SELECT new org.apache.openjpa.persistence.jdbc.query.model.GameBean(g)
FROM Game g";
+        EntityManager em = emf.createEntityManager();
+       
+        List<?> names = em.createQuery(jpql).getResultList();
+        assertNotNull(names);
+        assertEquals(0, names.size());
+    }
+
+    public void testNewJavaObjectNamedQueryResultList() {
+        EntityManager em = emf.createEntityManager();
+
+        List<?> names = em.createNamedQuery("getDataSourceFieldById").getResultList();
+        assertNotNull(names);
+        assertEquals(0, names.size());
+    }
+}

Propchange: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java?rev=1299276&view=auto
==============================================================================
--- openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java
(added)
+++ openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java
Sat Mar 10 21:26:31 2012
@@ -0,0 +1,108 @@
+/*
+ * 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.jdbc.query.domain;
+
+import java.io.Serializable;
+import javax.persistence.*;
+
+import org.apache.openjpa.persistence.Generator;
+
+import java.util.List;
+
+/**
+ * The persistent class for the DtaSrc database table.
+ * 
+ */
+@Entity
+public class DtaSrc implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	@Id
+	@GeneratedValue(generator=Generator.UUID_STRING)
+	private String id;
+
+	@Column(length=100, nullable=false)
+	private String name;
+
+	@OneToMany(mappedBy="dataSource", cascade=CascadeType.ALL)
+	private List<DtaSrcField> fields;
+
+    public DtaSrc() {
+    }
+
+	public String getId() {
+		return this.id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return this.name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((id == null)? 0 : id.hashCode());
+		return result;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj) {
+			return true;
+		}
+		if (obj == null) {
+			return false;
+		}
+		if (!(obj instanceof DtaSrc)) {
+			return false;
+		}
+		DtaSrc other = (DtaSrc) obj;
+		if (id == null) {
+			if (other.id != null) {
+				return false;
+			}
+		} else if (!id.equals(other.id)) {
+			return false;
+		}
+		return true;
+	}
+
+	public void setFields(List<DtaSrcField> fields) {
+		this.fields = fields;
+	}
+
+	public List<DtaSrcField> getFields() {
+		return fields;
+	}
+}

Propchange: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java?rev=1299276&view=auto
==============================================================================
--- openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java
(added)
+++ openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java
Sat Mar 10 21:26:31 2012
@@ -0,0 +1,111 @@
+/*
+ * 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.jdbc.query.domain;
+
+import java.io.Serializable;
+import javax.persistence.*;
+
+import org.apache.openjpa.persistence.Generator;
+
+/**
+ * The persistent class for the DtaSrcField database table.
+ * 
+ */
+@Entity
+@NamedQueries({
+@NamedQuery(name = "getDataSourceFieldById", 
+    query = "SELECT new org.apache.openjpa.persistence.jdbc.query.domain.DtaSrcFieldBean(d)
" +
+                "FROM DtaSrcField d WHERE d.id=:id")
+})
+public class DtaSrcField implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	@Id
+	@GeneratedValue(generator=Generator.UUID_STRING)
+	private String id;
+
+	@ManyToOne
+	@JoinColumn(name="dataSourceId", referencedColumnName="id")
+	private DtaSrc dataSource;
+
+	@Column(length=100, nullable=false)
+	private String name;
+
+    public DtaSrcField() {
+    }
+
+	public String getId() {
+		return this.id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public DtaSrc getDatasource() {
+		return this.dataSource;
+	}
+
+	public void setDataSourceId(DtaSrc datasource) {
+		this.dataSource = datasource;
+	}
+
+	public String getName() {
+		return this.name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + (id == null ? 0 : id.hashCode());
+		return result;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj) {
+			return true;
+		}
+		if (obj == null) {
+			return false;
+		}
+		if (!(obj instanceof DtaSrcField)) {
+			return false;
+		}
+		DtaSrcField other = (DtaSrcField) obj;
+		if (id == null) {
+			if (other.id != null) {
+				return false;
+			}
+		} else if (!id.equals(other.id)) {
+			return false;
+		}
+		return true;
+	}
+}

Propchange: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java?rev=1299276&view=auto
==============================================================================
--- openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java
(added)
+++ openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java
Sat Mar 10 21:26:31 2012
@@ -0,0 +1,31 @@
+/*
+ * 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.jdbc.query.domain;
+
+public class DtaSrcFieldBean {
+    public DtaSrcField field;
+
+    public DtaSrcFieldBean(DtaSrcField field) {
+        this.field = field;
+    }
+
+    public String getId() {
+        return field.getId();
+    }
+}

Propchange: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java?rev=1299276&view=auto
==============================================================================
--- openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java
(added)
+++ openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java
Sat Mar 10 21:26:31 2012
@@ -0,0 +1,27 @@
+/*
+ * 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.jdbc.query.domain;
+
+public class GameBean {
+    public Game game;
+
+    public GameBean(Game game) {
+        this.game = game;
+    }
+}

Propchange: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java?rev=1299276&r1=1299275&r2=1299276&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
Sat Mar 10 21:26:31 2012
@@ -37,7 +37,7 @@ import org.apache.openjpa.lib.util.Close
  * as it WILL NOT fall back to non-DBCP mode if they are missing. For automatic
  * usage of Commons DBCP when available, use AutoDriverDataSource instead.
  */
-public abstract class DBCPDriverDataSource
+public class DBCPDriverDataSource
 extends SimpleDriverDataSource implements Configurable, Closeable {
 
     private static String DBCPPACKAGENAME = "org.apache.commons.dbcp";

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java?rev=1299276&r1=1299275&r2=1299276&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
Sat Mar 10 21:26:31 2012
@@ -31,6 +31,7 @@ import java.util.Properties;
 import java.util.logging.Logger;
 
 import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.lib.jdbc.ConnectionDecorator;
 import org.apache.openjpa.lib.jdbc.DelegatingDataSource;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
@@ -146,8 +147,7 @@ public class SimpleDriverDataSource
         return _connectionFactoryProperties;
     }
 
-    @SuppressWarnings("unchecked")
-    public List createConnectionDecorators() {
+    public List<ConnectionDecorator> createConnectionDecorators() {
         return null;
     }
 
@@ -206,8 +206,7 @@ public class SimpleDriverDataSource
     
 
     // java.sql.Wrapper implementation (JDBC 4)
-    @SuppressWarnings("unchecked")
-    public boolean isWrapperFor(Class iface) {
+    public boolean isWrapperFor(Class<?> iface) {
         return iface.isAssignableFrom(SimpleDriverDataSource.class);
     }
 
@@ -218,9 +217,9 @@ public class SimpleDriverDataSource
         else
             return null;
     }
-    
+
     // Java 7 methods follow
-    
+
     public Logger getParentLogger() throws SQLFeatureNotSupportedException{
     	throw new SQLFeatureNotSupportedException();
     }

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java?rev=1299276&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java
Sat Mar 10 21:26:31 2012
@@ -0,0 +1,75 @@
+/*
+ * 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.jdbc.query;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.jdbc.query.domain.DtaSrc;
+import org.apache.openjpa.persistence.jdbc.query.domain.DtaSrcField;
+import org.apache.openjpa.persistence.jdbc.query.domain.Game;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+/**
+ * Tests "openjpa.jdbc.DriverDataSource=dbcp" option.
+ *  
+ * Further details can be found in
+ * <A HREF="https://issues.apache.org/jira/browse/OPENJPA-2153">OPENJPA-2153</A>
+ * 
+ */
+public class TestNewJavaObjectQuery extends SingleEMFTestCase {   
+    public void setUp() {
+        super.setUp(CLEAR_TABLES, Game.class,
+                DtaSrc.class, DtaSrcField.class, 
+                "openjpa.jdbc.DriverDataSource", "dbcp");
+    }
+
+//	void createData() throws Exception {
+//		EntityManager em = emf.createEntityManager();
+//		em.getTransaction().begin();
+//        Class[] classes = { Game.class, IndoorGame.class, Scrabble.class,
+//				Chess.class };
+//		for (Class cls : classes) {
+//			for (int i = 1; i <= 4; i++) {
+//				Game p = (Game) cls.newInstance();
+//				p.setName(cls.getSimpleName() + "-" + i);
+//				em.persist(p);
+//			}
+//		}
+//		em.getTransaction().commit();
+//	}
+
+    public void testNewJavaObjectQueryResultList() {
+        String jpql = "SELECT new org.apache.openjpa.persistence.jdbc.query.model.GameBean(g)
FROM Game g";
+        EntityManager em = emf.createEntityManager();
+       
+        List<?> names = em.createQuery(jpql).getResultList();
+        assertNotNull(names);
+        assertEquals(0, names.size());
+    }
+
+    public void testNewJavaObjectNamedQueryResultList() {
+        EntityManager em = emf.createEntityManager();
+
+        List<?> names = em.createNamedQuery("getDataSourceFieldById").getResultList();
+        assertNotNull(names);
+        assertEquals(0, names.size());
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNewJavaObjectQuery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java?rev=1299276&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java
Sat Mar 10 21:26:31 2012
@@ -0,0 +1,108 @@
+/*
+ * 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.jdbc.query.domain;
+
+import java.io.Serializable;
+import javax.persistence.*;
+
+import org.apache.openjpa.persistence.Generator;
+
+import java.util.List;
+
+/**
+ * The persistent class for the DtaSrc database table.
+ * 
+ */
+@Entity
+public class DtaSrc implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	@Id
+	@GeneratedValue(generator=Generator.UUID_STRING)
+	private String id;
+
+	@Column(length=100, nullable=false)
+	private String name;
+
+	@OneToMany(mappedBy="dataSource", cascade=CascadeType.ALL)
+	private List<DtaSrcField> fields;
+
+    public DtaSrc() {
+    }
+
+	public String getId() {
+		return this.id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return this.name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((id == null)? 0 : id.hashCode());
+		return result;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj) {
+			return true;
+		}
+		if (obj == null) {
+			return false;
+		}
+		if (!(obj instanceof DtaSrc)) {
+			return false;
+		}
+		DtaSrc other = (DtaSrc) obj;
+		if (id == null) {
+			if (other.id != null) {
+				return false;
+			}
+		} else if (!id.equals(other.id)) {
+			return false;
+		}
+		return true;
+	}
+
+	public void setFields(List<DtaSrcField> fields) {
+		this.fields = fields;
+	}
+
+	public List<DtaSrcField> getFields() {
+		return fields;
+	}
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrc.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java?rev=1299276&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java
Sat Mar 10 21:26:31 2012
@@ -0,0 +1,111 @@
+/*
+ * 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.jdbc.query.domain;
+
+import java.io.Serializable;
+import javax.persistence.*;
+
+import org.apache.openjpa.persistence.Generator;
+
+/**
+ * The persistent class for the DtaSrcField database table.
+ * 
+ */
+@Entity
+@NamedQueries({
+@NamedQuery(name = "getDataSourceFieldById", 
+    query = "SELECT new org.apache.openjpa.persistence.jdbc.query.domain.DtaSrcFieldBean(d)
" +
+                "FROM DtaSrcField d WHERE d.id=:id")
+})
+public class DtaSrcField implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	@Id
+	@GeneratedValue(generator=Generator.UUID_STRING)
+	private String id;
+
+	@ManyToOne
+	@JoinColumn(name="dataSourceId", referencedColumnName="id")
+	private DtaSrc dataSource;
+
+	@Column(length=100, nullable=false)
+	private String name;
+
+    public DtaSrcField() {
+    }
+
+	public String getId() {
+		return this.id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public DtaSrc getDatasource() {
+		return this.dataSource;
+	}
+
+	public void setDataSourceId(DtaSrc datasource) {
+		this.dataSource = datasource;
+	}
+
+	public String getName() {
+		return this.name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + (id == null ? 0 : id.hashCode());
+		return result;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj) {
+			return true;
+		}
+		if (obj == null) {
+			return false;
+		}
+		if (!(obj instanceof DtaSrcField)) {
+			return false;
+		}
+		DtaSrcField other = (DtaSrcField) obj;
+		if (id == null) {
+			if (other.id != null) {
+				return false;
+			}
+		} else if (!id.equals(other.id)) {
+			return false;
+		}
+		return true;
+	}
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java?rev=1299276&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java
Sat Mar 10 21:26:31 2012
@@ -0,0 +1,31 @@
+/*
+ * 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.jdbc.query.domain;
+
+public class DtaSrcFieldBean {
+    public DtaSrcField field;
+
+    public DtaSrcFieldBean(DtaSrcField field) {
+        this.field = field;
+    }
+
+    public String getId() {
+        return field.getId();
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/DtaSrcFieldBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java?rev=1299276&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java
Sat Mar 10 21:26:31 2012
@@ -0,0 +1,27 @@
+/*
+ * 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.jdbc.query.domain;
+
+public class GameBean {
+    public Game game;
+
+    public GameBean(Game game) {
+        this.game = game;
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/domain/GameBean.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message