openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r627979 [17/39] - in /openjpa/trunk: openjpa-lib/src/test/java/org/apache/openjpa/lib/test/ openjpa-persistence-jdbc/ openjpa-persistence-jdbc/src/test/java/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/ openjpa-per...
Date Fri, 15 Feb 2008 09:20:40 GMT
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,46 @@
+/*
+ * 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.common.apps;
+
+/**
+ * <p>Persistent type used in testing.</p>
+ *
+ * @author Abe White
+ */
+public class StateImagePC {
+
+    private int intField;
+    private StateImagePC stateImage;
+
+    public int getIntField() {
+        return this.intField;
+    }
+
+    public void setIntField(int intField) {
+        this.intField = intField;
+    }
+
+    public StateImagePC getStateImage() {
+        return this.stateImage;
+    }
+
+    public void setStateImage(StateImagePC stateImage) {
+        this.stateImage = stateImage;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC2.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC2.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.common.apps;
+
+/**
+ * <p>Persistent type used in testing.</p>
+ *
+ * @author Abe White
+ */
+public class StateImagePC2
+    extends StateImagePC {
+
+    private String stringField;
+
+    public String getStringField() {
+        return this.stringField;
+    }
+
+    public void setStringField(String stringField) {
+        this.stringField = stringField;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC3.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC3.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC3.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/StateImagePC3.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,46 @@
+/*
+ * 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.common.apps;
+
+/**
+ * <p>Persistent type used in testing.</p>
+ *
+ * @author Abe White
+ */
+public class StateImagePC3 {
+
+    private int lockField;
+    private int nolockField;
+
+    public int getLockField() {
+        return lockField;
+    }
+
+    public void setLockField(int i) {
+        lockField = i;
+    }
+
+    public int getNoLockField() {
+        return nolockField;
+    }
+
+    public void setNoLockField(int i) {
+        nolockField = i;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/TransactionalClassPC.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/TransactionalClassPC.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/TransactionalClassPC.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/TransactionalClassPC.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.common.apps;
+
+import org.apache.openjpa.kernel.*;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import java.lang.annotation.Annotation;
+
+/**
+ * <p>Transactional type used in testing.</p>
+ *
+ * @author Abe White
+ */
+@Entity
+public class TransactionalClassPC {
+	@Id
+    private int intField;
+
+    public int getIntField() {
+        return this.intField;
+    }
+
+    public void setIntField(int intField) {
+        this.intField = intField;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/UnknownSubclassParent.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/UnknownSubclassParent.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/UnknownSubclassParent.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/UnknownSubclassParent.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,34 @@
+/*
+ * 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.common.apps;
+
+public class UnknownSubclassParent {
+
+    private String parentString;
+
+    public void setParentString(String parentString) {
+        this.parentString = parentString;
+    }
+
+    public String getParentString() {
+        return this.parentString;
+    }
+}
+
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/CompositeId.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/CompositeId.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/CompositeId.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/CompositeId.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,89 @@
+/*
+ * 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.common.apps.mappingApp;
+
+import java.io.Serializable;
+
+/** Denotes a composite identity combining a String and Integer field.
+ * 
+ * @author <A HREF="mailto:pinaki.poddar@gmail.com>Pinaki Poddar</A>
+ *
+ */
+public class CompositeId implements Serializable {
+	public Integer id;
+	public String  name;
+	
+	public CompositeId () 
+	{
+	}
+
+	public CompositeId (String idString)
+	{
+		int index = idString.indexOf(':');
+		id = Integer.parseInt(idString.substring(0,index));
+		name = idString.substring(index+1);
+	}
+
+	public CompositeId (Integer id, String name)
+	{
+		this.id   = id;
+		this.name = name;
+	}
+
+	public Integer getId()
+	{
+		return id;
+	}
+
+	public void setId(Integer id)
+	{
+		this.id = id;
+	}
+
+	public String getName()
+	{
+		return name;
+	}
+
+	public void setName(String name)
+	{
+		this.name = name;
+	}
+	
+	public String toString() 
+	{
+		return id + ":" + name;
+	}
+	
+	@Override
+	public boolean equals (Object other)
+	{
+		if (other instanceof CompositeId==false)
+			return false;
+		
+		CompositeId that = (CompositeId) other;
+		return id.equals(that.id) && name.equals(that.name);
+	}
+	
+	@Override
+	public int hashCode () 
+	{
+		return id.hashCode()+name.hashCode();
+	}
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/Entity1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/Entity1.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/Entity1.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/Entity1.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,117 @@
+/*
+ * 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.common.apps.mappingApp;
+
+import java.io.Serializable;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EntityResult;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.OneToOne;
+import javax.persistence.SqlResultSetMapping;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+
+@Entity
+@Table(name="entity_1")
+@Inheritance(strategy=InheritanceType.JOINED)
+@SqlResultSetMapping(name="NativeTestResult", entities=@EntityResult(entityClass=Entity1.class))
+public class Entity1 implements Serializable
+{
+	private static final long serialVersionUID = 2882935803066041165L;
+
+	@Id
+	protected long pk;
+
+	@Basic
+	@Column(length=35)
+	protected String stringField;
+
+	@Basic
+	protected int intField;
+
+	@OneToOne(cascade={CascadeType.REMOVE, CascadeType.PERSIST})
+	protected Entity2 entity2Field;
+
+	@Version
+	protected int versionField;
+
+	public Entity1()
+	{}
+
+	public Entity1 (long pk, String stringField, int intField)
+	{
+		this.pk = pk;
+		this.stringField = stringField;
+		this.intField = intField;
+	}
+
+
+	public long getPk ()
+	{
+		return pk;
+	}
+
+
+	public void setStringField (String val)
+	{
+		stringField = val;
+	}
+
+
+	public String getStringField ()
+	{
+		return stringField;
+	}
+
+
+	public void setIntField (int val)
+	{
+		intField = val;
+	}
+
+
+	public int getIntField ()
+	{
+		return intField;
+	}
+
+
+	public void setEntity2Field (Entity2 val)
+	{
+		entity2Field = val;
+	}
+
+
+	public Entity2 getEntity2Field ()
+	{
+		return entity2Field;
+	}
+
+	public String toString()
+	{
+		return("PK: "+pk+" StringField: "+stringField+" IntField: "+intField);
+	}
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/Entity2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/Entity2.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/Entity2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/Entity2.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,99 @@
+/*
+ * 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.common.apps.mappingApp;
+
+import java.io.Serializable;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+
+
+//@Entity(name="entity2ExplicitName")
+//@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
+/**FIX-ME 
+ * 
+ * It should complain if i uncomment the above strategies...but it does
+ */
+@Entity
+public class Entity2 implements Serializable
+{
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = 4723739219953167343L;
+
+	@Id
+	protected long pk;
+
+	@Basic
+	@Column(length=35)
+	protected String stringField;
+
+	@Basic
+	protected int intField;
+
+	public Entity2()
+	{}
+
+
+	public Entity2 (long pk, String stringField, int intField)
+	{
+		this.pk = pk;
+		this.stringField = stringField;
+		this.intField = intField;
+	}
+
+
+	public long getPk ()
+	{
+		return pk;
+	}
+
+
+	public void setStringField (String val)
+	{
+		stringField = val;
+	}
+
+
+	public String getStringField ()
+	{
+		return stringField;
+	}
+
+	public void setIntField (int val)
+	{
+		intField = val;
+	}
+
+
+	public int getIntField ()
+	{
+		return intField;
+	}
+
+	public String toString()
+	{
+		return("PK: "+pk+" StringField: "+stringField+" IntField: "+intField);
+	}
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/EntityWithCompositeId.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/EntityWithCompositeId.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/EntityWithCompositeId.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/EntityWithCompositeId.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,68 @@
+/*
+ * 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.common.apps.mappingApp;
+
+import javax.persistence.*;
+
+@Entity
+@IdClass(CompositeId.class)
+@Table(name="COMPOSITE_ID")
+public class EntityWithCompositeId {
+	private Integer id;   // this must match the field in CompositeId
+	private String  name; // this must match the field in CompositeId
+	private String  value;
+	
+	public EntityWithCompositeId() {
+		super();
+	}
+	
+	@Id
+	@Column(name="ID")
+	public Integer getId () 
+	{
+		return id;
+	}
+
+	@Id
+	@Column(name="NAME")
+	public String getName () {
+		return name;
+	}
+	
+	
+	@Column(name="VALUE")
+	public String getValue () 
+	{
+		return value;
+	}
+	
+	public void setId (Integer id) {
+		this.id = id;
+	}
+	
+	public void setName (String name) 
+	{
+		this.name = name;
+	}
+	
+	public void setValue (String value)
+	{
+		this.value = value;
+	}
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/OwnerOfEntityWithCompositeId.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/OwnerOfEntityWithCompositeId.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/OwnerOfEntityWithCompositeId.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/OwnerOfEntityWithCompositeId.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,118 @@
+/*
+ * 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.common.apps.mappingApp;
+
+import javax.persistence.*;
+
+@SqlResultSetMappings(value={
+@SqlResultSetMapping(name="SQLSelectsBothEndOfTheRelation",
+		entities={
+			@EntityResult(entityClass=OwnerOfEntityWithCompositeId.class,
+				fields={
+				@FieldResult(name="name",          column="OWNER_NAME"),
+				@FieldResult(name="relation.id",   column="REL_ID"),
+				@FieldResult(name="relation.name", column="REL_NAME")
+				}
+			),
+			@EntityResult(entityClass=EntityWithCompositeId.class,
+				fields={
+					@FieldResult(name="id",  column="C_ID"),
+					@FieldResult(name="name", column="C_NAME"),
+					@FieldResult(name="value", column="C_VALUE")
+				}
+			)
+		}
+),
+@SqlResultSetMapping(name="SQLSelectsOnlyOneEndOfTheRelation",
+		entities={
+			@EntityResult(entityClass=OwnerOfEntityWithCompositeId.class,
+				fields={
+				@FieldResult(name="name",          column="OWNER_NAME"),
+				@FieldResult(name="relation.id",   column="REL_ID"),
+				@FieldResult(name="relation.name", column="REL_NAME")
+				}
+			)
+		}
+),
+@SqlResultSetMapping(name="SQLSelectsUnrelatedInstances",
+		entities={
+			@EntityResult(entityClass=OwnerOfEntityWithCompositeId.class,
+				fields={
+				@FieldResult(name="name",          column="OWNER_NAME"),
+				@FieldResult(name="relation.id",   column="REL_ID"),
+				@FieldResult(name="relation.name", column="REL_NAME")
+				}
+			),
+			@EntityResult(entityClass=EntityWithCompositeId.class,
+				fields={
+					@FieldResult(name="id",    column="C_ID"),
+					@FieldResult(name="name",  column="C_NAME"),
+					@FieldResult(name="value", column="C_VALUE")
+				}
+			)
+		}
+)
+
+})
+
+@Entity
+@Table(name="OWNER_OF_COMPOSITE_ID")
+public class OwnerOfEntityWithCompositeId {
+	
+	private String                 name;
+	private EntityWithCompositeId  relation;
+	
+	public OwnerOfEntityWithCompositeId() {
+		super();
+	}
+	
+	public OwnerOfEntityWithCompositeId (String name)
+	{
+		setName (name);
+	}
+	
+	@Id
+	@Column(name="NAME")
+	public String getName () 
+	{
+		return name;
+	}
+	
+	@OneToOne(cascade=CascadeType.ALL)
+	@JoinColumns({
+		@JoinColumn(name="RELATION_ID",referencedColumnName="ID"),
+		@JoinColumn(name="RELATION_NAME", referencedColumnName="NAME")
+	})
+	
+	public EntityWithCompositeId getRelation()
+	{
+		return relation;
+	}
+	
+	
+	public void setName (String name)
+	{
+		this.name = name;
+	}
+	
+	public void setRelation (EntityWithCompositeId relation)
+	{
+		this.relation = relation;
+	}
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/RecursiveEntityWithCompositeId.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/RecursiveEntityWithCompositeId.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/RecursiveEntityWithCompositeId.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/RecursiveEntityWithCompositeId.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,104 @@
+/*
+ * 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.common.apps.mappingApp;
+
+import javax.persistence.*;
+
+@SqlResultSetMappings(value={
+	@SqlResultSetMapping(name="SQLSelectsChainedRelation",
+		entities={
+			@EntityResult(entityClass=RecursiveEntityWithCompositeId.class,
+				fields={
+				
+				@FieldResult(name="id",                   column="T0_ID"),
+				@FieldResult(name="name",                 column="T0_NAME"),
+				@FieldResult(name="relation.id",          column="T0_REL_ID"),
+				@FieldResult(name="relation.name",        column="T0_REL_NAME"),
+				@FieldResult(name="relation.relation.id", column="T1_REL_ID"),
+				@FieldResult(name="relation.relation.name", column="T1_REL_NAME"),
+				@FieldResult(name="relation.relation.relation.id", column="T2_REL_ID"),
+				@FieldResult(name="relation.relation.relation.name", column="T2_REL_NAME")
+				
+				}
+			)
+		}
+	)
+  }
+)
+ 
+@Entity
+@IdClass(CompositeId.class)
+@Table(name="RECURSIVE_ENTITY")
+
+public class RecursiveEntityWithCompositeId {
+	private Integer id;   // this must match the field in CompositeId
+	private String  name; // this must match the field in CompositeId
+	private int     value;// a non-primary key field 
+	private RecursiveEntityWithCompositeId  relation; // self-related
+	
+	public RecursiveEntityWithCompositeId() {
+		super();
+	}
+	
+	@Id
+	@Column(name="ID")
+	public Integer getId () 
+	{
+		return id;
+	}
+
+	@Id
+	@Column(name="NAME")
+	public String getName () {
+		return name;
+	}
+	
+	@Column(name="VALUE")
+	public int getValue(){
+	   return value;	
+	}
+	
+	@OneToOne(cascade=CascadeType.ALL)
+	@JoinColumns({
+		@JoinColumn(name="RELATION_ID",   referencedColumnName="ID"),
+		@JoinColumn(name="RELATION_NAME", referencedColumnName="NAME")
+	})
+	public RecursiveEntityWithCompositeId getRelation() 
+	{
+		return relation;
+	}
+	
+	public void setId (Integer id) {
+		this.id = id;
+	}
+	
+	public void setName (String name) 
+	{
+		this.name = name;
+	}
+	public void setValue (int value) 
+	{
+		this.value = value;
+	}
+	
+	public void setRelation (RecursiveEntityWithCompositeId relation)
+	{
+		this.relation = relation;
+	}
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapAddress.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapAddress.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapAddress.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapAddress.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,177 @@
+/*
+ * 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.common.apps.mappingApp;
+
+import java.io.Serializable;
+
+import javax.persistence.*;
+
+/** This domain class uses a all possible nature of annotations. Nature of
+ * annotation from the point of view of nature of result they produce are
+ * the following
+ * <pre>
+ * #entity-result      #column-result       nature
+ * 0                     1+                 SCALAR_ONLY
+ * 1                     0                  SINGLE_CLASS
+ * 1                     1+                 SINGLE_CLASS_AND_SCALAR
+ * 1+                    0                  MULTI_CLASS
+ * 1+                    1+                 MULTI_CLASS_AND_SCALAR
+ * </pre> 
+ * 
+ */
+@SqlResultSetMappings(value={
+		/** Specifies only scalars and no entity.
+		 * 
+		 */		
+				@SqlResultSetMapping(name="SCALAR_ONLY",
+				    columns={
+						@ColumnResult(name="NAME")
+					}
+				),
+		/** Specifies one entity and no scalar.
+		 * 
+		 */		
+				@SqlResultSetMapping(name="SINGLE_CLASS",
+					entities={
+						@EntityResult(entityClass=SQLMapPerson.class)
+					}
+				),
+				
+				/** Specifies one entity and one or more scalar.
+				 * 
+				 */				
+				@SqlResultSetMapping(name="SINGLE_CLASS_AND_SCALAR",
+					entities={
+						@EntityResult(entityClass=SQLMapPerson.class)
+					},
+					columns={
+						@ColumnResult(name="name")
+					}
+				),
+				
+				/** Specifies more than one entity and no scalar.
+				 * 
+				 */				
+				@SqlResultSetMapping(name="MULTI_CLASS",
+					entities={
+						@EntityResult(entityClass=SQLMapPerson.class),
+						@EntityResult(entityClass=SQLMapAddress.class)
+					}
+				),
+				
+				/** Specifies more than one entity and one or more scalar.
+				 * 
+				 */				
+				@SqlResultSetMapping(name="MULTI_CLASS_AND_SCALAR",
+					entities={
+						@EntityResult(entityClass=SQLMapPerson.class),
+						@EntityResult(entityClass=SQLMapAddress.class)
+					},
+					columns={
+						@ColumnResult(name="name"),
+						@ColumnResult(name="state")
+					}
+				),
+
+				@SqlResultSetMapping(name="MappingWithTraversal",
+					entities={
+						@EntityResult(entityClass=SQLMapAddress.class,
+					    fields={
+							@FieldResult(name="id",    column="ADDR_ID"),
+							@FieldResult(name="street",column="ADDR_STREET"),
+							@FieldResult(name="state", column="ADDR_STATE"),
+							@FieldResult(name="zip",   column="ADDR_ZIP")
+						}),
+						@EntityResult(entityClass=SQLMapPerson.class,
+						 fields={
+							@FieldResult(name="name",    column="MY_NAME"),
+							@FieldResult(name="address", column="MY_ADDRESS")
+						 }
+						)
+					}
+				)
+				
+				
+			}
+		) 
+
+
+@Entity
+@Table(name = "SQLMAP_ADDRESS")
+public class SQLMapAddress implements Serializable {
+	private int    id;
+	private String street;
+	private String state;
+	private int    zip;
+
+	protected SQLMapAddress() {
+
+	}
+
+	public SQLMapAddress(int id, String street, String state, int zip) {
+		this.id = id;
+		setStreet(street);
+		setState(state);
+		setZip(zip);
+	}
+
+	@Id
+	public int getId ()
+	{
+		return id;
+	}
+
+	public void setId (int id)
+	{
+		this.id = id;
+	}
+
+	@Column(name="STATE")
+	public String getState() {
+		return state;
+	}
+
+	public void setState(String state) {
+		this.state = state;
+	}
+
+	@Column(name="STREET")
+	public String getStreet() {
+		return street;
+	}
+
+	public void setStreet(String street) {
+		this.street = street;
+	}
+
+	public int getZip() {
+		return zip;
+	}
+
+	@Column(name="ZIP")
+	public void setZip(int zip) {
+		this.zip = zip;
+	}
+	
+	@PostLoad
+	protected void inform() {
+		System.out.println("Loaded" + this);
+	}
+
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapItem.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapItem.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapItem.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapItem.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,157 @@
+/*
+ * 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.common.apps.mappingApp;
+
+import java.io.Serializable;
+
+import javax.persistence.*;
+
+
+/** This simple domain class without any relationship is for testing basic 
+ * SQL Result Set mapping functionality.
+ * This class uses Application Identity.
+ * The annotation specified herein examplifies test cases of accessing
+ * with or without identity fields, aliased column names etc. 
+ */ 
+@SqlResultSetMappings(value = {
+	/**
+	 *  This mapping is the same as the native query that
+	 *  takes a class argument.
+	 *  <code>SELECT id,name,price FROM ITEM WHERE name='WINE'</code>
+	 */ 		
+	@SqlResultSetMapping(name = "MappingEquivalentToClassQuery", 
+		entities = { @EntityResult(entityClass = SQLMapItem.class) 
+	}),
+
+	/**
+	 * This mapping is similar to the native query that takes a class argument
+	 * but the query specifies aliases for the projection columns.
+	 *  <code>SELECT id AS ITEM_ID,name AS ITEM_NAME FROM ITEM
+	 *  WHERE NAME='WINE'</code>
+	 */				
+	@SqlResultSetMapping(name = "MappingWithAliasedColumnName", 
+		entities = { @EntityResult(entityClass = SQLMapItem.class, 
+			fields = {
+				@FieldResult(name = "id",   column = "ITEM_ID"),
+				@FieldResult(name = "name", column = "ITEM_NAME") }) 
+			}),
+
+	/**
+	 * This mapping specifes only few fields of the application class.
+	 * 
+	 */ 		
+	@SqlResultSetMapping(name="MappingWithPartialFields",
+		entities={@EntityResult(entityClass=SQLMapItem.class,
+			fields={
+				@FieldResult(name="id", column="id")
+			})
+		}),
+
+	@SqlResultSetMapping(name="MappingWithPartialFieldsExcludingIdField",
+		entities={@EntityResult(entityClass=SQLMapItem.class,
+			fields={
+				@FieldResult(name="name", column="name")
+				})
+	
+		})
+})
+
+@Entity
+@Table(name = "SQLMAP_ITEM")
+public class SQLMapItem
+	implements Serializable
+{
+
+	private int id;
+	private String name;
+	private float  price;
+
+
+	protected SQLMapItem()
+	{
+	}
+
+
+	public SQLMapItem(int id)
+	{
+		this.id = id;
+	}
+
+
+	public SQLMapItem(int id, String name)
+	{
+		this.id = id;
+		this.name = name;
+	}
+
+
+	public SQLMapItem(int id, String name, int price)
+	{
+		this.id = id;
+		this.name = name;
+		this.price = price;
+	}
+
+
+	public String toString()
+	{
+		return getId() + ":"+getName();
+		//System.identityHashCode(this) + ":[" + id + "." + name + "]";
+	}
+
+
+	@Id
+	@Column(name="ID")
+	public int getId()
+	{
+		return id;
+	}
+
+	public void setId(int id)
+	{
+		System.out.println("setId " + id);
+		this.id = id;
+	}
+
+	@Column(name="NAME")
+	public String getName()
+	{
+		return name;
+	}
+
+
+	public void setName(String name)
+	{
+		System.out.println("setName " + name);
+		this.name = name;
+	}
+
+
+	@Column(name="PRICE")
+	public float getPrice()
+	{
+		return price;
+	}
+
+
+	public void setPrice(float price)
+	{
+		this.price = price;
+	}
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapOrder.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapOrder.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapOrder.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapOrder.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,89 @@
+/*
+ * 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.common.apps.mappingApp;
+
+import java.io.Serializable;
+
+import javax.persistence.*;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+/** Exemplifies a mapping that is overwritten in orm.xml file.
+ * 
+ * @author <A HREF="mailto:pinaki.poddar@gmail.com>Pinaki Poddar</A>
+ *
+ */
+@SqlResultSetMapping(name="Overwritten by Descriptor",
+		entities={
+			@EntityResult(entityClass=SQLMapOrder.class)
+		},
+		columns={
+			@ColumnResult(name="id")
+		}
+	)
+
+@Entity
+@Table(name = "SQLMAP_ORDER")
+public class SQLMapOrder implements Serializable {
+	@Id
+	int id;
+
+	int quantity;
+
+	@OneToOne
+	SQLMapItem item;
+
+	protected SQLMapOrder() {
+	}
+
+	public SQLMapOrder(int id) {
+		this(id, 1);
+	}
+
+	public SQLMapOrder(int id, int quantity) {
+		this.id = id;
+		this.quantity = 1;
+		this.item = null;
+	}
+
+	public SQLMapItem getItem() {
+		return item;
+	}
+
+	public void setItem(SQLMapItem item) {
+		this.item = item;
+	}
+
+	public int getQuantity() {
+		return quantity;
+	}
+
+	public void setQuantity(int quantity) {
+		this.quantity = quantity;
+	}
+
+	public int getId() {
+		return id;
+	}
+	@PostLoad
+	protected void inform() {
+		System.out.println("Loaded" + this);
+	}
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapPerson.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapPerson.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapPerson.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/mappingApp/SQLMapPerson.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,92 @@
+/*
+ * 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.common.apps.mappingApp;
+
+import java.io.Serializable;
+
+import javax.persistence.*;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+/** 
+ * @author ppoddar
+ *
+ */
+
+@SqlResultSetMapping (name="MappingWithSelfJoin",
+		columns={
+			@ColumnResult(name="MY_NAME"),
+			@ColumnResult(name="PARTNER_NAME")
+		}
+)
+@Entity
+@Table(name = "SQLMAP_PERSON")
+public class SQLMapPerson implements Serializable {
+	private String name;
+	private SQLMapAddress address;
+	private SQLMapPerson partner;
+
+
+	protected SQLMapPerson() {
+	}
+
+	public SQLMapPerson(String name) {
+		this.name = name;
+	}
+
+	public SQLMapPerson(String name, SQLMapAddress address) {
+		this.name = name;
+		setAddress(address);
+	}
+
+	@Id
+	public String getName() {
+		return name;
+	}
+	
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@OneToOne(cascade=CascadeType.ALL)
+	@JoinColumn(name="ADDRESS_ID")
+	public SQLMapAddress getAddress() {
+		return address;
+	}
+
+	public void setAddress(SQLMapAddress address) {
+		this.address = address;
+	}
+
+
+	@OneToOne
+	public SQLMapPerson getPartner() {
+		return partner;
+	}
+
+	public void setPartner(SQLMapPerson partner) {
+		this.partner = partner;
+	}
+//	@PostLoad
+//	protected void inform() {
+//		System.out.println("Loaded" + this);
+//	}
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/BaseJDBCTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/BaseJDBCTest.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/BaseJDBCTest.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/BaseJDBCTest.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,189 @@
+/*
+ * BaseJDBCTest.java
+ *
+ * Created on October 9, 2006, 12:56 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+/*
+ * 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.kernel;
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.*;
+import javax.management.IntrospectionException;
+import org.apache.openjpa.kernel.Broker;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
+import org.apache.openjpa.kernel.jpql.JPQLParser;
+import org.apache.openjpa.lib.conf.ConfigurationProvider;
+import org.apache.openjpa.lib.conf.Configurations;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+
+
+
+import java.lang.annotation.Annotation;
+import junit.framework.*;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.JPAFacadeHelper;
+
+
+public class BaseJDBCTest extends org.apache.openjpa.persistence.common.utils.AbstractTestCase{
+    
+    
+    private static Map _sysprops = new HashMap();
+    
+    
+    /** Creates a new instance of BaseJDBCTest */
+    public BaseJDBCTest() {
+    }
+    
+    public BaseJDBCTest(String name) 
+    {
+        super(name, "jdbccactusapp");
+    }
+    
+    protected OpenJPAEntityManager getPM() {
+        return (OpenJPAEntityManager)currentEntityManager();
+    }
+    
+    protected OpenJPAEntityManager getPM(boolean optimistic,boolean retainValues) {
+        OpenJPAEntityManager em = (OpenJPAEntityManager)currentEntityManager();
+        em.setNontransactionalRead(true);
+        em.setRetainState(retainValues);
+        em.setOptimistic(optimistic);
+        return em;
+    }
+    
+    /**
+     * Delete all instances of the given class.
+     */
+    protected  int deleteAll(Broker broker, Class clazz) {
+        return deleteAll(broker, clazz, true);
+    }
+    
+    /**
+     * Delete all instances of the given class.
+     */
+    protected int deleteAll(Broker broker, Class clazz,
+            boolean subclasses) {
+        final boolean useDeleteByQuery = false;
+        
+        if (useDeleteByQuery) {
+            org.apache.openjpa.kernel.Query query = broker.newQuery(
+                    JPQLParser.LANG_JPQL, clazz, "");
+            query.setCandidateType(clazz, subclasses);
+            return (int) query.deleteAll();
+        } else {
+            org.apache.openjpa.kernel.Extent extent =
+                    broker.newExtent(clazz, subclasses);
+            List list = extent.list();
+            int size = list.size();
+            broker.deleteAll(list, null);
+            return size;
+        }
+    }
+    
+    /**
+     * Delete all instances of the given class.
+     */
+    protected int deleteAll(OpenJPAEntityManager pm, Class clazz) {
+        return deleteAll(JPAFacadeHelper.toBroker(pm), clazz);
+    }
+    
+    /**
+     * Delete all instances of the given class.
+     */
+    protected int deleteAll(OpenJPAEntityManager pm, Class clazz,
+            boolean subclasses) {
+        return deleteAll(JPAFacadeHelper.toBroker(pm), clazz, subclasses);
+    }
+    
+    
+    protected Object persist(Object ob) {
+        Broker broker = getBrokerFactory().newBroker();
+        broker.begin();
+        broker.persist(ob, null);
+        Object id = broker.getObjectId(ob);
+        broker.commit();
+        broker.close();
+        return id;
+    }
+    
+    protected OpenJPAStateManager getStateManager(Object obj,OpenJPAEntityManager pm) {
+        return getStateManager(obj,pm);
+    }
+    
+    protected Properties getProperties() {
+        return getProperties(null);
+    }
+    
+    /**
+     * Return the runtime properties, optionally overriding or setting
+     * some via the given array, which should be in the form
+     * { key, val, key, val, ... }.
+     */
+    protected synchronized Properties getProperties(String[] props) {
+        Properties p = new Properties(System.getProperties());
+        String str = p.getProperty("openjpa.properties", "kodo.properties");
+        if (str != null && str.length() > 0) {
+            // cache system properties to reduce load on file system
+            Properties loaded = (Properties) _sysprops.get(str);
+            if (loaded == null) {
+                loaded = new Properties();
+                ConfigurationProvider cp = (ConfigurationProvider) Configurations.getProperty(str, null);
+                
+                if (cp != null)
+                    loaded.putAll(cp.getProperties());
+                _sysprops.put(str, loaded);
+            }
+            p.putAll(loaded);
+        }
+        
+        for (int i = 0; props != null && i < props.length; i += 2) {
+            if (props[i + 1] != null) {
+                // remove any duplicate kodo/openjpa property so we don't clash
+                if (props[i].startsWith("openjpa."))
+                    p.remove("openjpa." + props[i].substring(5));
+                else if (props[i].startsWith("openjpa."))
+                    p.remove("openjpa." + props[i].substring(8));
+                
+                p.setProperty(props[i], props[i + 1]);
+            } else {
+                p.remove(props[i]);
+            }
+        }
+        return p;
+    }
+    
+    
+    
+    
+    
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/JDBCTestCase.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/JDBCTestCase.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/JDBCTestCase.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/JDBCTestCase.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,72 @@
+/*
+ * JDBCTestCase.java
+ *
+ * Created on September 29, 2006, 3:23 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+/*
+ * 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.kernel;
+
+
+import org.apache.openjpa.persistence.jdbc.common.apps.*;
+import java.util.*;
+import org.apache.openjpa.conf.*;
+import org.apache.openjpa.util.*;
+import org.apache.openjpa.kernel.*;
+import org.apache.openjpa.jdbc.conf.*;
+import org.apache.openjpa.jdbc.kernel.*;
+import org.apache.openjpa.jdbc.meta.*;
+import org.apache.openjpa.jdbc.meta.strats.*;
+
+
+
+
+public abstract class JDBCTestCase extends BaseJDBCTest {
+    
+    /** Creates a new instance of JDBCTestCase */
+    public JDBCTestCase() {
+    }
+    
+    public JDBCTestCase(String name) {
+        super(name);
+    }
+    public Class getDefaultInheritanceStrategy() {
+        return getClassMapping(RuntimeTest2.class).getStrategy().getClass();
+    }
+
+    public ClassMapping getClassMapping(Class c) {
+        
+        OpenJPAConfiguration jdoConf = getConfiguration();
+        return ((JDBCConfiguration) jdoConf).getMappingRepositoryInstance().
+            getMapping(c, getClass().getClassLoader(), true);
+    }
+
+    public FieldMapping getFieldMapping(Class c, String field) {
+        return getClassMapping(c).getFieldMapping(field);
+    }
+
+    public boolean isInheritanceStrategyVertical() {
+        return VerticalClassStrategy.class.
+            isAssignableFrom(getDefaultInheritanceStrategy());
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestByteArrayAppId.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestByteArrayAppId.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestByteArrayAppId.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestByteArrayAppId.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,373 @@
+/*
+ * 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.kernel;
+/*
+ * TestByteArrayAppId.java
+ *
+ * Created on October 2, 2006, 10:56 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+
+import org.apache.openjpa.persistence.jdbc.common.apps.*;
+import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+
+import java.util.*;
+
+
+import java.lang.annotation.Annotation;
+import junit.framework.*;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.jdbc.meta.MappingTool;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.kernel.Extent;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
+import org.apache.openjpa.kernel.Query;
+
+
+public class TestByteArrayAppId extends BaseJDBCTest {
+    
+    private static boolean _init = false;
+    private OpenJPAEntityManagerFactory _pmf = null;
+    
+    
+    /** Creates a new instance of TestByteArrayAppId */
+    public TestByteArrayAppId(String name) 
+    {
+    	super(name);
+    }
+    
+    public boolean skipTest() {
+        return getCurrentPlatform() != AbstractTestCase.Platform.DB2;
+    }
+    
+    public void setUp()
+    throws Exception {
+        // we have to use getbytes/setbytes for byte arrays to work properly
+        _pmf =(OpenJPAEntityManagerFactory) getEmf(getProps());
+        
+        if (!_init) {
+            initialize((JDBCConfiguration) ((OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast(_pmf)).getConfiguration());
+            _init = true;
+        }
+        EntityManager pm = _pmf.createEntityManager();
+        startTx(pm);
+        
+       deleteAll(ByteArrayPKPC.class,pm);
+        endTx(pm);
+        pm.close();
+        pm = currentEntityManager();
+        startTx(pm);
+        ByteArrayPKPC2 testBytes = new ByteArrayPKPC2(new byte[]{ 1, 2 },
+                "child");
+        testBytes.setSubfield("sub");
+        testBytes.setParent(new ByteArrayPKPC(new byte[]{ 3, 4 }, "parent"));
+        pm.persist(testBytes);
+        endTx(pm);
+        pm.close();
+    }
+    
+    public void tearDown()
+    throws Exception {
+        // closing the pmf every time slows things down too much b/c
+        // schema reflection is so slow on DB2
+        //	try { _pmf.close (); } catch (Exception e) {}
+        
+        super.tearDown();
+    }
+    
+    private void initialize(JDBCConfiguration conf)
+    throws Exception {
+        
+        EntityManager em= currentEntityManager();
+        OpenJPAEntityManager kem = OpenJPAPersistence.cast (em);
+        //JDBCConfiguration conf = (JDBCConfiguration) kem.getConfiguration();        
+        
+        MappingTool tool = new MappingTool((JDBCConfiguration)
+        		((OpenJPAEntityManagerSPI) kem).getConfiguration(), MappingTool.ACTION_REFRESH, false);
+        tool.run(ByteArrayPKPC.class);
+        tool.run(ByteArrayPKPC2.class);
+        tool.record();
+    }
+    
+    /**
+     * Tests that application identity classes are returned correctly.
+     */
+    public void testGetObjectIdClass() {
+        EntityManager em= currentEntityManager();
+        OpenJPAEntityManager pm = OpenJPAPersistence.cast (em);
+
+        
+        assertEquals(ByteArrayPKPCId.class,
+                pm.getObjectIdClass(ByteArrayPKPC.class));
+        assertEquals(ByteArrayPKPCId.class,
+                pm.getObjectIdClass(ByteArrayPKPC2.class));
+        pm.close();
+        em.close();
+    }
+    
+    /**
+     * Tests finding an instance by a manually-created id value.
+     */
+    public void testGetSubclassObjectById() {
+        ByteArrayPKPC2 bytes2 = getChild();
+        assertNotNull(bytes2);
+        assertEquals(1, bytes2.getPK()[0]);
+        assertEquals(2, bytes2.getPK()[1]);
+        assertEquals("child", bytes2.getStringField());
+        assertEquals("sub", bytes2.getSubfield());
+        assertNotNull(bytes2.getParent());
+        assertEquals(3, bytes2.getParent().getPK()[0]);
+        assertEquals(4, bytes2.getParent().getPK()[1]);
+        assertEquals("parent", bytes2.getParent().getStringField());
+        assertNull(bytes2.getParent().getParent());
+        //FIXME next line commented 
+        //JDOHelper.getPersistenceManager(bytes2).close();
+    }
+    
+    /**
+     * Tests finding an instance by a manually-created id value.
+     */
+    public void testGetObjectById() {
+        ByteArrayPKPC bytes = getParent();
+        assertNotNull(bytes);
+        assertEquals(3, bytes.getPK()[0]);
+        assertEquals(4, bytes.getPK()[1]);
+        assertEquals("parent", bytes.getStringField());
+        assertNull(bytes.getParent());
+        //FIXME next line commented 
+        //JDOHelper.getPersistenceManager(bytes).close();
+    }
+    
+    /**
+     * Tests that the oid instances returned from the pm are copied to
+     * prevent by-reference modification by the user.
+     */
+    public void testGetObjectId() {
+        
+        EntityManager em= currentEntityManager();
+        OpenJPAEntityManager kem = OpenJPAPersistence.cast (em);
+        if (! ((OpenJPAEntityManagerSPI) kem).getConfiguration().getCompatibilityInstance().getCopyObjectIds())
+            return;
+        
+        ByteArrayPKPCId oid = new ByteArrayPKPCId();
+        oid.pk = new byte[]{ 1, 2 };
+        ByteArrayPKPC bytes = (ByteArrayPKPC) kem.getObjectId(oid);
+        ByteArrayPKPCId oidCopy = (ByteArrayPKPCId) kem.getObjectId(bytes);
+        assertTrue("Oid not copied.", oid != oidCopy);
+        assertEquals(1, oidCopy.pk[0]);
+        assertEquals(2, oidCopy.pk[1]);
+        
+        em.close();
+        kem.close();
+    }
+    
+    /**
+     * Tests that changing primary key values will fail.
+     */
+    public void testChangeIdentity() {
+        ByteArrayPKPC2 bytes = getChild();
+        OpenJPAEntityManager pm = OpenJPAPersistence.getEntityManager(bytes);
+        startTx(pm);
+        
+        // make sure setting to same value is OK
+        bytes.setPK(bytes.getPK());
+        try {
+            bytes.setPK(new byte[]{ 5, 6 });
+            fail("Allowed changing of pk.");
+        } catch (Exception je) {
+        }
+        rollbackTx(pm);
+        pm.close();
+    }
+    
+    /**
+     * Tests that pk fields are retained on state transition to hollow.
+     */
+    public void testPKRetain() {
+        ByteArrayPKPC2 bytes = getChild();
+        OpenJPAEntityManager pm = OpenJPAPersistence.getEntityManager(bytes);
+        
+        //FIXME next line commented .... need substitute API
+        //pm.currentTransaction().setNontransactionalRead(false);
+        
+        startTx(pm);
+        bytes.setParent(null);
+        endTx(pm);        
+        
+        // bytes should still allow access to oid fields
+        assertEquals(1, bytes.getPK()[0]);
+        assertEquals(2, bytes.getPK()[1]);
+        try {
+            bytes.getParent();
+            fail("Allowed read of non-pk value outside of transaction.");
+        } catch (Exception je) {
+        }
+        try {
+            bytes.setPK(new byte[]{ 5, 6 });
+            fail("Allowed setting of pk value outside of transaction.");
+        } catch (Exception je) {
+        }
+        pm.close();
+    }
+    
+    public void testDeleteAndInsert() {
+        EntityManager em= currentEntityManager();
+        OpenJPAEntityManager kem = OpenJPAPersistence.cast (em);
+        
+        startTx(kem);
+       
+        for (int i = 0; i < 20; i++) {
+            ByteArrayPKPC bytes = new ByteArrayPKPC(new byte[]
+            { (byte) (i + 5), (byte) (i + 6) }, String.valueOf(i));
+            kem.persist(bytes);
+        }
+        endTx(kem);        
+        
+        kem.close();
+        
+        kem = _pmf.createEntityManager();
+        startTx(kem);
+        Extent extent = (Extent) kem.createExtent(ByteArrayPKPC.class,false);
+        kem.detachAll(extent.list());
+        extent.closeAll();
+        
+        ByteArrayPKPC owner = new ByteArrayPKPC();
+        kem.persist(owner);
+        owner.setPK(new byte[]{ 100, 101 });
+        owner.setStringField("owner");
+        
+        // make new instances with same oids persistent
+        for (int i = 0; i < 20; i++) {
+            ByteArrayPKPC bytes = new ByteArrayPKPC(new byte[]
+            { (byte) (i + 5), (byte) (i + 6) }, String.valueOf(i));
+            kem.persist(bytes);
+            assertEquals(bytes, getStateManager(bytes, kem).getManagedInstance());
+            owner.getRels().add(bytes);
+        }
+        
+        endTx(kem);  
+        
+        Object oid = kem.getObjectId(owner);
+        assertOwner(kem, oid);
+        kem.close();
+        
+        kem = _pmf.createEntityManager();
+        assertOwner(kem, oid);
+        em.close();
+        kem.close();
+    }
+    
+    public void testQuery() {
+        EntityManager pm = _pmf.createEntityManager();
+        //FIXME jthomas - partly commented 
+        //Query q = pm.newQuery(ByteArrayPKPC.class, "pk == bytes");
+        Query q =null;//= pm.newQuery(ByteArrayPKPC.class, "pk == bytes");
+        q.declareParameters("byte[] bytes");
+        //FIXME jthomas - no execute for byte 
+        //Collection results = (Collection) q.execute(new byte[]{ 1, 2 });
+        Collection results =null;//= (Collection) q.execute(new byte[]{ 1, 2 });
+        assertEquals(1, results.size());
+        ByteArrayPKPC2 child = (ByteArrayPKPC2) results.iterator().next();
+        assertEquals("child", child.getStringField());
+        q.closeAll();
+        pm.close();
+    }
+    
+    public void testConflictingIds() {
+        OpenJPAEntityManager pm = _pmf.createEntityManager();
+        startTx(pm);     
+        
+        // make a bunch of objects persistent with the same initial pk values
+        ByteArrayPKPC owner = new ByteArrayPKPC();
+        pm.persist(owner);
+        owner.setPK(new byte[]{ 100, 101 });
+        owner.setStringField("owner");
+        for (int i = 0; i < 20; i++) {
+            ByteArrayPKPC bytes = new ByteArrayPKPC();
+            pm.persist(bytes);
+            assertEquals(bytes, getStateManager(bytes, pm).
+                    getManagedInstance());
+            bytes.setPK(new byte[]{ (byte) (i + 5), (byte) (i + 6) });
+            bytes.setStringField(String.valueOf(i));
+            owner.getRels().add(bytes);
+        }
+        endTx(pm);
+        Object oid = pm.getObjectId(owner);
+        assertOwner(pm, oid);
+        pm.close();
+        
+        pm = _pmf.createEntityManager();
+        assertOwner(pm, oid);
+        pm.close();
+    }
+    
+    private void assertOwner(OpenJPAEntityManager pm, Object oid) {
+        ByteArrayPKPC owner = (ByteArrayPKPC) pm.getObjectId(oid);
+        assertEquals(100, owner.getPK()[0]);
+        assertEquals(101, owner.getPK()[1]);
+        assertEquals("owner", owner.getStringField());
+        List rels = owner.getRels();
+        assertEquals(20, rels.size());
+        for (int i = 0; i < rels.size(); i++) {
+            ByteArrayPKPC bytes = (ByteArrayPKPC) rels.get(i);
+            assertEquals(i + 5, bytes.getPK()[0]);
+            assertEquals(i + 6, bytes.getPK()[1]);
+            assertEquals(String.valueOf(i), bytes.getStringField());
+        }
+    }
+    
+    private ByteArrayPKPC getParent() {
+        ByteArrayPKPCId oid = new ByteArrayPKPCId();
+        oid.pk = new byte[]{ 3, 4 };
+        OpenJPAEntityManager pm = _pmf.createEntityManager();
+        return (ByteArrayPKPC) pm.getObjectId(oid);
+    }
+    
+    private ByteArrayPKPC2 getChild() {
+        ByteArrayPKPCId oid = new ByteArrayPKPCId();
+        oid.pk = new byte[]{ 1, 2 };
+        OpenJPAEntityManager pm = _pmf.createEntityManager();
+        return (ByteArrayPKPC2) pm.getObjectId(oid);
+    }
+    
+    public static void main(String[] args) {
+       // main();
+    }
+    
+    private Map getProps() {
+        Map props=new HashMap();
+        props.put("openjpa.jdbc.DBDictionary", "");
+        props.put("UseGetBytesForBlobs", "true");
+        props.put("UseSetBytesForBlobs", "true");
+        props.put("BatchLimit", "0");
+        
+        return props;
+    }
+    
+    
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestCircularFK.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestCircularFK.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestCircularFK.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestCircularFK.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,139 @@
+/*
+ * 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.kernel;
+
+
+import java.util.*;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.*;
+
+
+import java.lang.annotation.Annotation;
+import junit.framework.*;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+
+public class TestCircularFK extends BaseJDBCTest{
+    
+    private Object _oid1 = null;
+    private Object _oid2 = null;
+    
+    public TestCircularFK(String name) {
+        super(name);
+    }
+    
+    /** Creates a new instance of TestCircularFK */
+    public TestCircularFK() {
+    }
+    
+    public void setUp() {
+        OpenJPAEntityManager pm = getPM();
+        
+        startTx(pm);
+       deleteAll(CircularFKPC.class,pm);
+       deleteAll(CircularFKPC2.class,pm);
+        endTx(pm);
+        endEm(pm);
+        
+        
+        CircularFKPC pc1 = new CircularFKPC();
+        pc1.setStringField("pc1");
+        CircularFKPC2 pc2 = new CircularFKPC2();
+        pc2.setStringField("pc2");
+        pc1.setFKField(pc2);
+        pc2.setFKField(pc1);
+        
+        pm = getPM();
+        startTx(pm);
+        pm.persist(pc1);
+        endTx(pm);
+        _oid1 = pm.getObjectId(pc1);
+        _oid2 = pm.getObjectId(pc2);
+        endEm(pm);
+    }
+    
+    public void testInsert() {
+        // inserts are tested in setup; just make sure the inserts
+        // actually worked
+        OpenJPAEntityManager pm = getPM();
+        CircularFKPC pc1 = (CircularFKPC) pm.find(CircularFKPC.class,_oid1);
+        CircularFKPC2 pc2 = (CircularFKPC2) pm.find(CircularFKPC2.class,_oid2);
+        assertNotNull(pc1);
+        assertNotNull(pc2);
+        assertEquals("pc1", pc1.getStringField());
+        assertEquals("pc2", pc2.getStringField());
+        assertEquals(pc2, pc1.getFKField());
+        assertEquals(pc1, pc2.getFKField());
+        pm.close();
+    }
+    
+    public void testDelete() {
+        OpenJPAEntityManager pm = getPM();
+        CircularFKPC pc1 = (CircularFKPC) pm.find(CircularFKPC.class,_oid1);
+        CircularFKPC2 pc2 = (CircularFKPC2) pm.find(CircularFKPC2.class,_oid2);
+        startTx(pm);
+        pm.remove(pc1);
+        pm.remove(pc2);
+        endTx(pm);
+        endEm(pm);
+        
+        pm = getPM();
+        try {
+            pm.find(CircularFKPC.class,_oid1);
+            fail("PC1 still exists!");
+        } catch (Exception jdse) {
+        }
+        try {
+            pm.find(CircularFKPC2.class,_oid2);
+            fail("PC2 still exists!");
+        } catch (Exception jdse) {
+        }
+        endEm(pm);
+    }
+    
+    public void testUpdate() {
+        OpenJPAEntityManager pm = getPM();
+        CircularFKPC pc1 = (CircularFKPC) pm.find(CircularFKPC.class,_oid1);
+        CircularFKPC2 pc2 = (CircularFKPC2) pm.find(CircularFKPC2.class,_oid2);
+        
+        startTx(pm);;
+        CircularFKPC2 pc3 = new CircularFKPC2();
+        pc3.setStringField("pc3");
+        pc3.setFKField(pc1);
+        pc1.setFKField(pc3);
+        pc2.setFKField(null);
+        endTx(pm);;
+        pm.close();
+        
+        pm = getPM();
+        pc1 = (CircularFKPC) pm.find(CircularFKPC.class,_oid1);
+        pc2 = (CircularFKPC2) pm.find(CircularFKPC2.class,_oid2);
+        assertNotNull(pc1);
+        assertNotNull(pc2);
+        assertEquals("pc1", pc1.getStringField());
+        assertEquals("pc2", pc2.getStringField());
+        assertNotNull(pc1.getFKField());
+        assertEquals("pc3", pc1.getFKField().getStringField());
+        assertEquals(pc1, pc1.getFKField().getFKField());
+        assertNull(pc2.getFKField());
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestDataStoreTrips.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestDataStoreTrips.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestDataStoreTrips.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/kernel/TestDataStoreTrips.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,199 @@
+/*
+ * TestDataStoreTrips.java
+ *
+ * Created on September 29, 2006, 4:48 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+/*
+ * 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.kernel;
+
+import java.util.*;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.*;
+
+
+import java.lang.annotation.Annotation;
+import junit.framework.*;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.lib.jdbc.AbstractJDBCListener;
+import org.apache.openjpa.lib.jdbc.JDBCEvent;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.jdbc.meta.ClassMapping;
+import org.apache.openjpa.persistence.Extent;
+
+
+
+public class TestDataStoreTrips extends BaseJDBCTest{
+
+
+//    private boolean  = true;//Boolean.valueOf(bool);
+	
+    private OpenJPAEntityManagerFactory _factory = null;
+    private Object _oid = null;
+    private SelectCounter _counter = null;
+    
+    /** Creates a new instance of TestDataStoreTrips */
+    public TestDataStoreTrips() {
+    }
+    public TestDataStoreTrips(String name) {
+        super(name);
+    }
+    
+    public void setUp()
+        throws Exception {
+       deleteAll(DataStoreTripsPC.class);
+
+        // figure out what table to look for in SQL statements
+        EntityManager em= currentEntityManager();
+        OpenJPAEntityManager kem = OpenJPAPersistence.cast (em);
+        JDBCConfiguration conf = (JDBCConfiguration) ((OpenJPAEntityManagerSPI) kem).getConfiguration();        
+
+        ClassMapping mapping = conf.getMappingRepositoryInstance().getMapping
+            (DataStoreTripsPC.class, null, true);
+        String table = conf.getDBDictionaryInstance()
+            .getFullName(mapping.getTable(), false);
+
+        // get factory with counter listener
+        _factory = getEmf();
+/*                getPMFactory(new String[]{
+            "openjpa.jdbc.JDBCListeners",
+            SelectCounter.class.getName() + "(Table=" + table + ")",
+            "openjpa.Compatibility",
+            "ValidateTrueChecksStore=true"
+        });
+*/
+        
+        OpenJPAEntityManager pm = _factory.createEntityManager();
+        startTx(pm);
+        
+        DataStoreTripsPC pc = new DataStoreTripsPC(0);
+        pm.persist(pc);
+        _oid = pm.getObjectId(pc);
+
+        for (int i = 1; i < 10; i++)
+              pm.persist(new DataStoreTripsPC(i));
+        endTx(pm);
+        em.close();
+
+        // do a query so that the subclass list will get initialized and
+        // won't count as a select
+        pm = _factory.createEntityManager();
+        pm.getObjectId(_oid);
+        pm.close();
+
+        _counter = (SelectCounter) ((JDBCConfiguration)
+        		((OpenJPAEntityManagerFactorySPI) _factory).getConfiguration()).getJDBCListenerInstances()[0];
+        _counter.selects = 0;
+        _counter.counts = 0;
+    }
+
+    public void testTrips() {
+        OpenJPAEntityManager pm = _factory.createEntityManager();
+        Extent ext = pm.createExtent(DataStoreTripsPC.class, true);
+        for (Iterator itr = ext.iterator(); itr.hasNext();)
+            itr.next();
+        ext.closeAll();
+        pm.close();
+
+        // there might be more than 1 trip if subclasses need to be
+        // initialized and so forth, but make sure there isn't more than
+        // 1 + # objects trips to the DB
+        assertTrue(_counter.selects > 0);
+        assertTrue("Should have been 1-3 trips to the data store; got "
+            + _counter.selects, _counter.selects < 5);
+    }
+
+    public void testExistsCalls() {
+        OpenJPAEntityManager pm = _factory.createEntityManager();
+
+        // first time there shouldn't be any call to exists b/c the data
+        // needs to be loaded
+        pm.getObjectId(_oid);
+        assertEquals(0, _counter.counts);
+        assertEquals(1, _counter.selects);
+
+        // this time there should be a call b/c data is already loaded but
+        // we're still asking to validate
+        pm.getObjectId(_oid);
+        assertEquals(1, _counter.counts);
+        assertEquals(2, _counter.selects);
+        pm.getObjectId(_oid);
+        assertEquals(2, _counter.counts);
+        assertEquals(3, _counter.selects);
+
+        // shouldn't be a call if validate is false; no select b/c data loaded
+        pm.getObjectId(_oid);
+        assertEquals(2, _counter.counts);
+        assertEquals(3, _counter.selects);
+
+        // this will hollow the object
+        //FIXME jthomas ...need to find a substitute
+        //pm.currentTransaction().setOptimistic(false);
+        startTx(pm);
+        
+
+        // no count call b/c loading data
+        pm.getObjectId(_oid);
+        assertEquals(2, _counter.counts);
+        assertEquals(4, _counter.selects);
+
+        // no count call b/c transactional; no select b/c data loaded
+        pm.getObjectId(_oid);
+        assertEquals(2, _counter.counts);
+        assertEquals(4, _counter.selects);
+
+        rollbackTx(pm);
+        pm.close();
+    }
+
+    public static class SelectCounter
+        extends AbstractJDBCListener {
+
+        public int selects = 0;
+        public int counts = 0;
+
+        private String _table = null;
+
+        public void setTable(String table) {
+            _table = table;
+        }
+
+        public void beforeExecuteStatement(JDBCEvent event) {
+            if (event.getSQL().indexOf(_table) != -1)
+                selects++;
+            {
+                if (event.getSQL().indexOf(" COUNT(") != -1)
+                    counts++;
+            }
+        }
+    }
+    
+    
+}



Mime
View raw message