labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r568737 - in /labs/fluid: ./ src/main/java/org/apache/openjpa/sdo/ src/main/java/org/apache/openjpa/sdo/mapping/ src/main/resources/org/apache/openjpa/sdo/ src/test/java/example/basic/ src/test/java/org/apache/openjpa/sdo/ src/test/java/tes...
Date Wed, 22 Aug 2007 19:44:55 GMT
Author: ppoddar
Date: Wed Aug 22 12:44:53 2007
New Revision: 568737

URL: http://svn.apache.org/viewvc?rev=568737&view=rev
Log:
Bytecode generation NOT working. Savepoint commit before changing to new enhancement-less option

Modified:
    labs/fluid/.classpath
    labs/fluid/src/main/java/org/apache/openjpa/sdo/ImplHelper.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/SDO2POJOGenerator.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOEntityManager.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOInstanceMapping.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOMappingRepository.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOMetaDataFactory.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOTypeParser.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOTypeRepository.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/AbstractPropertyMapping.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/IdenticalTypeMapping.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/IdentityMapping.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PrimitiveListMapping.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PrimitiveMapping.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PropertyMapping.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/RelationListMapping.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/RelationMapping.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/SDOMappingStrategy.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/TypeMapping.java
    labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/VersionMapping.java
    labs/fluid/src/main/resources/org/apache/openjpa/sdo/localizer.properties
    labs/fluid/src/test/java/example/basic/TestCRUD.java
    labs/fluid/src/test/java/example/basic/TestRelation.java
    labs/fluid/src/test/java/org/apache/openjpa/sdo/TestSDO.java
    labs/fluid/src/test/java/test/common/AbstractSDOTest.java
    labs/fluid/src/test/resources/META-INF/books.xsd
    labs/fluid/src/test/resources/META-INF/persistence.xml

Modified: labs/fluid/.classpath
URL: http://svn.apache.org/viewvc/labs/fluid/.classpath?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/.classpath (original)
+++ labs/fluid/.classpath Wed Aug 22 12:44:53 2007
@@ -1,44 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry excluding="org/apache/openjpa/das/**" kind="src" path="src/main/java"/>
 	<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
-	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
-	<classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry excluding="example/das/**" kind="src" output="target/classes" path="src/test/java"/>
+	<classpathentry excluding="**/*.java" kind="src" output="target/classes" path="src/test/resources"/>
 	<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/ant/ant/1.6.5/ant-1.6.5.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/net/sourceforge/serp/serp/1.13.0/serp-1.13.0.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.0.1/geronimo-jms_1.1_spec-1.0.1.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/eclipse/xsd/xsd/2.2.2/xsd-2.2.2.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/commons-lang/commons-lang/2.1/commons-lang-2.1.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/commons-collections/commons-collections/3.2/commons-collections-3.2.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/eclipse/emf/ecore-change/2.2.2/ecore-change-2.2.2.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-j2ee-connector_1.5_spec/1.0.1/geronimo-j2ee-connector_1.5_spec-1.0.1.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1/geronimo-jta_1.1_spec-1.1.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/eclipse/emf/ecore-xmi/2.2.2/ecore-xmi-2.2.2.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/mysql/mysql-connector-java/5.0.4/mysql-connector-java-5.0.4.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/eclipse/emf/common/2.2.2/common-2.2.2.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.0/jaxb-api-2.0.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-jta_1.0.1B_spec/1.0.1/geronimo-jta_1.0.1B_spec-1.0.1.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/tuscany/sdo/tuscany-sdo-impl/1.0-incubating-beta1/tuscany-sdo-impl-1.0-incubating-beta1.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-jpa_3.0_spec/1.0/geronimo-jpa_3.0_spec-1.0.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/openjpa/openjpa/1.0.0-SNAPSHOT/openjpa-1.0.0-SNAPSHOT.jar" sourcepath="/OPENJPA_SRC">
-		<attributes>
-			<attribute name="javadoc_location" value="http://openjpa.apache.org/docs/latest/javadoc/index.html"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry exported="true" kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/commons-pool/commons-pool/1.3/commons-pool-1.3.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/commonj/sdo-api-r2.1/1.0-incubating-beta1/sdo-api-r2.1-1.0-incubating-beta1.jar">
-		<attributes>
-			<attribute name="javadoc_location" value="jar:file:/C:/Documents and Settings/ppoddar/.m2/repository/commonj/sdo-api-r2.1/1.0-incubating-beta1/sdo-api-r2.1-1.0-incubating-beta1-javadoc.jar!/"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry exported="true" kind="var" path="M2_REPO/javax/xml/bind/jsr173_api/1.0/jsr173_api-1.0.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/hsqldb/hsqldb/1.8.0.1/hsqldb-1.8.0.1.jar"/>
-	<classpathentry exported="true" kind="var" path="M2_REPO/org/eclipse/emf/ecore/2.2.2/ecore-2.2.2.jar"/>
-	<classpathentry exported="true" kind="lib" path="D:/lib/tuscany/das/rdb/target/tuscany-das-rdb-1.0-incubating-beta1.jar" sourcepath="D:/lib/tuscany/das/rdb/target/sdo-source"/>
+	<classpathentry exported="true" kind="lib" path="C:/Documents and Settings/ppoddar/.m2/repository/commonj/sdo-api-r2.1/1.0-incubating-beta1/sdo-api-r2.1-1.0-incubating-beta1.jar"/>
+	<classpathentry exported="true" kind="lib" path="C:/bea/modules/javax.persistence_1.0.jar"/>
+	<classpathentry exported="true" kind="lib" path="C:/bea/modules/javax.resource_1.5.jar"/>
+	<classpathentry exported="true" kind="lib" path="C:/bea/modules/javax.transaction_1.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="C:/bea/modules/junit_3.8.1/junit.jar"/>
+	<classpathentry exported="true" kind="lib" path="C:/bea/modules/com.bea.core.apache.commons.pool_1.3.0.jar"/>
+	<classpathentry exported="true" kind="lib" path="C:/bea/modules/com.bea.core.apache.commons.collections_3.2.0.jar"/>
+	<classpathentry exported="true" kind="lib" path="C:/bea/modules/com.bea.core.apache.commons.lang_2.1.0.jar"/>
+	<classpathentry exported="true" kind="lib" path="C:/Documents and Settings/ppoddar/.m2/repository/net/sourceforge/serp/serp/1.13.0/serp-1.13.0.jar" sourcepath="D:/lib/serp/src/main/java"/>
+	<classpathentry kind="lib" path="/OpenJPA/openjpa-all/target/openjpa-1.0.0-SNAPSHOT.jar" sourcepath="/OpenJPA/target/site/downloads/apache-openjpa-1.0.0-SNAPSHOT-source.zip"/>
 	<classpathentry kind="output" path="target/classes"/>
 </classpath>

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/ImplHelper.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/ImplHelper.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/ImplHelper.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/ImplHelper.java Wed Aug 22 12:44:53 2007
@@ -23,6 +23,7 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.util.UserException;
 
 import commonj.sdo.DataObject;
@@ -62,15 +63,15 @@
 	 * get method that will be invoked reflectively on the persistence capable
 	 * instance to obtain the value.
 	 */
-	public static Object getFieldValue(Property property, Object pc) {
-		String methodName = getMethodName("get", property);
-		try {
-			Method method = pc.getClass().getMethod(methodName, (Class[])null);
-			return method.invoke(pc, (Object[])null);
-		} catch (Exception e) {
-			throw new RuntimeException(e);
-		} 
-	}
+//	public static Object getFieldValue(Property property, Object pc) {
+//		String methodName = getMethodName("get", property);
+//		try {
+//			Method method = pc.getClass().getMethod(methodName, (Class[])null);
+//			return method.invoke(pc, (Object[])null);
+//		} catch (Exception e) {
+//			throw new RuntimeException(e);
+//		} 
+//	}
 	
 	/**
 	 * Get the name of Java class given the Type. The Java class name is 
@@ -123,7 +124,7 @@
 	 * 
 	 */
 	//TODO: Improve checking for identity property
-	public static Property getIdentity(Type type) {
+	public static Property getIdentityProperty(Type type) {
 		// If there is property named "id" of simple data type return it  
 		Property idProperty = type.getProperty("id");
 		if (idProperty != null && idProperty.getType().isDataType())
@@ -147,9 +148,6 @@
 				}
 			}
 		}
-		if (idProperty == null)
-			throw new UserException(_loc.get("missing-identity", type.getName())
-					.toString());
 		return idProperty;
 	}
 	
@@ -199,19 +197,19 @@
 	}
 	
 	/**
-	 * Gets the value of the {@link #getIdentity(Type) identity property}
+	 * Gets the value of the {@link #getIdentityProperty(Type) identity property}
 	 * of the given DataObject.
 	 */
 	public static Object getIdValue(DataObject data) {
-		return data.get(getIdentity(data.getType()));
+		return data.get(getIdentityProperty(data.getType()));
 	}
 	
 	/**
-	 * Sets the value of the {@link #getIdentity(Type) identity property}
+	 * Sets the value of the {@link #getIdentityProperty(Type) identity property}
 	 * of the given DataObject.
 	 */
 	public static void setIdValue(DataObject data, Object idValue) {
-		data.set(getIdentity(data.getType()), idValue);
+		data.set(getIdentityProperty(data.getType()), idValue);
 	}
 	
 	/**

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/SDO2POJOGenerator.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/SDO2POJOGenerator.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/SDO2POJOGenerator.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/SDO2POJOGenerator.java Wed Aug 22 12:44:53 2007
@@ -30,6 +30,7 @@
 import java.util.Map;
 
 import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.log.LogFactoryImpl;
 import org.apache.openjpa.lib.util.Files;
@@ -65,7 +66,7 @@
 	 *
 	 */
 	SDO2POJOGenerator() {
-		this(null);
+		this(new Flags());
 	}
 	
 	/**
@@ -73,7 +74,7 @@
 	 * 
 	 */
 	SDO2POJOGenerator(Flags flags) {
-		this.flags = (flags==null) ? new Flags() : flags;
+		this.flags = flags;
 		LogFactoryImpl logFactory = new LogFactoryImpl();
 		logFactory.setDefaultLevel(LogFactoryImpl.getLevel(flags.logLevel));
 		_log = logFactory.getLog(OpenJPAConfiguration.LOG_METADATA);
@@ -85,7 +86,7 @@
 	 * @param given Type can not be null, simple xsd data type or sequence.
 	 *  
 	 */
-	SourceCode getJavaClass(Type type) {
+	SourceCode getJavaSourceCode(Type type) {
 		if (type == null)
 			throw new NullPointerException(_loc.get("null-type").toString());
 		String typeName = type.getName();
@@ -107,47 +108,9 @@
 	}
 	
 	/**
-	 * Find user-defined SDO types in the given resource.  
-	 * 
-	 */
-	List<Type> findTypes(String resource) {
-		if (resource == null || !resource.endsWith(".xsd"))
-			return Collections.EMPTY_LIST;
-		if (_log.isInfoEnabled())
-			_log.info(_loc.get("parse-xml-schema", resource));
-		List<Type> result = new ArrayList<Type>();
-		InputStream xsdInputStream = Thread.currentThread()
-				.getContextClassLoader().getResourceAsStream(resource);
-		if (xsdInputStream == null) {
-			if (_log.isWarnEnabled()) {
-				_log.warn(_loc.get("xsd-not-found", resource).toString());
-			}
-			return result;
-		}
-		List types = XSDHelper.INSTANCE.define(xsdInputStream, null);
-
-		try {
-			for (Object t : types) {
-				if (t instanceof Type) {
-					Type type = (Type) t;
-					if (!(type.isDataType() || 
-						"DocumentRoot".equals(type.getName())))
-						result.add(type);
-				}
-			}
-		} finally  {
-			try {
-				xsdInputStream.close();
-			} catch (IOException e) {
-			}
-		}
-		return result;
-	}
-
-	/**
 	 * Generate source code for a Java Class corresponding to the given type.
 	 * <br>
-	 * The given type must declare a {@link ImplHelper#getIdentity(Type) 
+	 * The given type must declare a {@link ImplHelper#getIdentityProperty(Type) 
 	 * identity property and a {@link ImplHelper#getVersionProperty(Type)
 	 * version property}.
 	 * 
@@ -185,7 +148,7 @@
 						fieldTypeName, pm.getName()));
 			SourceCode.Field field = code.addField(fieldName, fieldTypeName)
 			    .makePrivate();
-			String[] annotations = pm.getAnnotations();
+			String[] annotations = pm.getAnnotationStrings();
 			for (String anno:annotations)
 				field.addAnnotation(anno);
 			field.addGetter();
@@ -243,11 +206,11 @@
 	 */
 	void run(String[] args) {
 		_cache.clear();
+		SDOTypeParser parser = new SDOTypeParser(new OpenJPAConfigurationImpl());
 		for (int i=0; args!=null && i<args.length; i++) {
-			List<Type> types = findTypes(args[i]);
+			List<Type> types = parser.parseXSDResource(args[i]);
 			for (Type type:types) {
-				if (!ImplHelper.isContainer(type))
-					getJavaClass(type);
+				getJavaSourceCode(type);
 			}
 		}
 		record();

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOEntityManager.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOEntityManager.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOEntityManager.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOEntityManager.java Wed Aug 22 12:44:53 2007
@@ -56,7 +56,10 @@
 		
 	public SDOEntityManager(SDOEntityManagerFactory emf, Broker broker) {
 		super(emf, broker);
-		repos = ((SDOMetaDataFactory)emf.getConfiguration().getMetaDataRepositoryInstance().getMetaDataFactory()).getSDOMappingRepository();
+		repos = ((SDOMetaDataFactory)emf.getConfiguration().
+				getMetaDataRepositoryInstance().
+				getMetaDataFactory()).
+				getSDOMappingRepository();
 	}
 	
 	/**

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOInstanceMapping.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOInstanceMapping.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOInstanceMapping.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOInstanceMapping.java Wed Aug 22 12:44:53 2007
@@ -65,7 +65,7 @@
 			return data;
 		}
 		data = newDataObject(type, pc);
-		TypeMapping tm = repos.getMapping(type);
+		TypeMapping tm = repos.getMapping(type, true);
 		List properties = data.getInstanceProperties();
 		for (Object p:properties) {
 			Property property = (Property)p;
@@ -73,7 +73,6 @@
 			try {
 				pm.populateDataObject(data, pc, this);
 			} catch (Exception e) {
-				// TODO Auto-generated catch block
 				e.printStackTrace();
 			}
 		}
@@ -96,7 +95,7 @@
 		
 		pc = newPC(cls, data);
 		cache(data, pc);
-		TypeMapping mapping = repos.getMapping(type);
+		TypeMapping mapping = repos.getMapping(type, true);
 		try {
 			List properties = data.getInstanceProperties();
 			for (Object p: properties) {
@@ -203,9 +202,9 @@
 				throw new OptimisticException(pc);
 		} else {
 			try {
-				repos.getMapping(data.getType()).getIdentityMapping()
+				repos.getMapping(data.getType(), true).getIdentityMapping()
 					.populateDataObject(data, pc, this);
-				repos.getMapping(data.getType()).getVersionMapping()
+				repos.getMapping(data.getType(), true).getVersionMapping()
 					.populateDataObject(data, pc, this);
 			} catch (Exception e) {
 				throw new PersistenceException(e);

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOMappingRepository.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOMappingRepository.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOMappingRepository.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOMappingRepository.java Wed Aug 22 12:44:53 2007
@@ -18,20 +18,59 @@
  */
 package org.apache.openjpa.sdo;
 
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.lang.instrument.IllegalClassFormatException;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+
+import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.enhance.PCClassFileTransformer;
+import org.apache.openjpa.enhance.PCEnhancer;
+import org.apache.openjpa.enhance.PersistenceCapable;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
+import org.apache.openjpa.jdbc.meta.FieldMapping;
+import org.apache.openjpa.jdbc.meta.MappingStrategyInstaller;
+import org.apache.openjpa.lib.conf.Configuration;
+import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.Files;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.meta.FieldMetaData;
+import org.apache.openjpa.meta.MetaDataFactory;
+import org.apache.openjpa.meta.MetaDataRepository;
+import org.apache.openjpa.sdo.mapping.AbstractPropertyMapping;
+import org.apache.openjpa.sdo.mapping.PropertyMapping;
 import org.apache.openjpa.sdo.mapping.SDOMappingStrategy;
 import org.apache.openjpa.sdo.mapping.TypeMapping;
+import org.apache.openjpa.util.InternalException;
+import org.apache.openjpa.util.UserException;
+
+import serp.bytecode.Annotation;
+import serp.bytecode.Annotations;
+import serp.bytecode.BCClass;
+import serp.bytecode.BCClassLoader;
+import serp.bytecode.BCField;
+import serp.bytecode.BCMethod;
+import serp.bytecode.Code;
+import serp.bytecode.Constants;
+import serp.bytecode.Project;
+import serp.util.Strings;
 
+import commonj.sdo.Property;
 import commonj.sdo.Type;
+import commonj.sdo.helper.TypeHelper;
 
 /**
  * Maintains mapping information for SDO Types to Java classes.
@@ -42,68 +81,97 @@
 public class SDOMappingRepository {
 	private static final Localizer _loc = 
 		Localizer.forPackage(SDOMetaDataFactory.class);
+	// Mapping for each SDO Type
 	private Map<Type, TypeMapping> mappings = new HashMap<Type, TypeMapping>();
+	// Associates SDO Type and Java Class
 	private BiDiMap<Type, Class> _cache = new BiDiMap<Type, Class>();
-	private Log _log;
+	
 	private OpenJPAConfiguration conf;
-	// This is static because of XSDHelper is static
-	private static Set<Type> parsedTypes = new HashSet<Type>();
+	private Log _log;
+	
+	private BCClassLoader throwAwayLoader;
+	private BCClassLoader enhancedLoader;
+	private File  _root;
 	
+	/**
+	 * Supply configuration.
+	 * 
+	 */
 	public SDOMappingRepository(OpenJPAConfiguration conf) {
 		super();
 		this.conf = conf;
 		_log = conf.getLog(OpenJPAConfiguration.LOG_METADATA);
+		_root = new File(System.getProperty("user.dir"));
 	}
 	
 	/**
-	 * Gets the strategy used for mapping of the given Type.
+	 * Gets the strategy used for mapping of the given SDO Type.
 	 * Constructs if necessary. 
+	 * Resolving a mapping if asked.
 	 */
-	public TypeMapping getMapping(Type type) {
+	public TypeMapping getMapping(Type type, boolean resolve) {
 		TypeMapping mapping = mappings.get(type);
+		Class cls = _cache.get(type);
 		if (mapping == null) {
-			Class cls = getJavaClass(type, true);
-			ClassMetaData cm = conf.getMetaDataRepositoryInstance()
-				.getCachedMetaData(cls);
-			ClassMapping cmd = (cm instanceof ClassMapping) ? 
-					(ClassMapping)cm : null;
-			mapping = SDOMappingStrategy.decideStrategy(type, cmd);
+			cls = getJavaClass(type, true);
+			if (_log.isInfoEnabled())
+				_log.info(_loc.get("type-mapping-new", type.getName(), toString(cls)).toString());
+			mapping = SDOMappingStrategy.decideStrategy(type, cls);
 			mappings.put(type, mapping);
 		}
+		if (resolve && !mapping.isResolved()) {
+			if (_log.isInfoEnabled())
+				_log.info(_loc.get("type-mapping-resolve", type.getName(), toString(cls)).toString());
+			MetaDataRepository mdr = conf.getMetaDataRepositoryInstance();
+			ClassMapping cm = (ClassMapping)mdr.getCachedMetaData(cls);
+			if (cm == null)
+				throw new RuntimeException(_loc.get("resolve-mapping-failed", toString(cls), mdr).toString());
+			mapping.resolve(cm);
+		}
 		return mapping;
 	}
 	
 	/**
 	 * Cache the given SDO Type and PersistenceCapable Java class in 
-	 * bi-directional map.
+	 * a bi-directional map.
 	 */
 	void cache(Type type, Class cls) {
-		if (_log.isTraceEnabled())
-			_log.trace(_loc.get("cache-sdo-type", new Object[]{this, 
-				type.getName(), cls.getName(), cls.getClassLoader()}).toString());
-		_cache.put(type, cls);
-		parsedTypes.add(type);
+//		if (!PersistenceCapable.class.isAssignableFrom(cls))
+//			throw new RuntimeException(_loc.get("cache-unenhanced", cls, cls.getClassLoader()).toString());
+		if (_cache.containsKey(type)) {
+			Class oldClass = _cache.get(type);
+			if (oldClass != cls) {
+				if (_log.isTraceEnabled())
+					_log.trace(_loc.get("cache-replace-sdo-type", 
+						type.getName(), toString(cls), toString(oldClass)).toString());
+			}
+		} else {
+			if (_log.isTraceEnabled())
+				_log.trace(_loc.get("cache-sdo-type", type.getName(), toString(cls)).toString());
+			_cache.put(type, cls);
+		}
 	}
 
 	/**
-	 * Get the Java Class corresponding to the given type.
+	 * Get the Java Class corresponding to the given SDO type.
 	 */
 	public Class getJavaClass(Type type, boolean mustExist) {
 		Class cls = _cache.get(type);
 		if (cls != null)
 			return cls;
-		
-		String fullName = ImplHelper.getFullClassName(type);
-		try {
-			cls = Class.forName(fullName);
-			if (cls != null) {
-				if (_log.isInfoEnabled())
-					_log.info(_loc.get("found-enhanced-cls", type.getName(), 
-							fullName, cls.getClassLoader().toString()));
+		if (mustExist) {
+			String fullName = ImplHelper.getFullClassName(type);
+			try {
+				cls = Class.forName(fullName, false, Thread.currentThread().getContextClassLoader());
 				cache(type, cls);
+			} catch (ClassNotFoundException ex) {
+				cls = generateEnhancedClass(type);
+				cache(type, cls);
+			} finally {
+//				ClassMetaData cm = conf.getMetaDataRepositoryInstance().getCachedMetaData(cls);
+//				cm.setIdentityType(ImplHelper.getIdentityProperty(type)==null ? 
+//						ClassMetaData.ID_DATASTORE : ClassMetaData.ID_APPLICATION);
 			}
-		} catch (ClassNotFoundException ex) {
-			throw new RuntimeException("class not found " + fullName);
 		}
 		return cls;
 	}
@@ -116,14 +184,12 @@
 	public Type getSDOType(Class cls, boolean mustExist) {
 		Type type = _cache.getReverse(cls);
 		if (type == null && mustExist) {
-			SDOMetaDataFactory mdf = (SDOMetaDataFactory)conf
-				.getMetaDataRepositoryInstance().getMetaDataFactory();
-			mdf.getPersistentTypeNames(true, Thread.currentThread()
-					.getContextClassLoader());
+			MetaDataFactory mdf = conf.getMetaDataRepositoryInstance().getMetaDataFactory();
+			mdf.getPersistentTypeNames(true, Thread.currentThread().getContextClassLoader());
 			type = _cache.getReverse(cls);
 			if (type == null)
 				throw new RuntimeException(_loc.get("no-type-for-class",
-					cls.getName(), cls.getClassLoader()).toString());
+					toString(cls)).toString());
 		}
 		return type;
 	}
@@ -133,21 +199,168 @@
 	 * Schema definitions if the named Type has not been cached.
 	 */
 	public Type getType(String name) throws TypeNotFoundException {
-		for (Type t:parsedTypes)
+		for (Type t:_cache.keySet())
 			if (t.getName().equals(name))
 				return t;
 		
-		SDOMetaDataFactory mdf = (SDOMetaDataFactory)conf
-			.getMetaDataRepositoryInstance().getMetaDataFactory();
-		mdf.getPersistentTypeNames(true, Thread.currentThread()
-				.getContextClassLoader());
+		MetaDataFactory mdf = conf.getMetaDataRepositoryInstance().getMetaDataFactory();
+		mdf.getPersistentTypeNames(true, Thread.currentThread().getContextClassLoader());
 		
-		for (Type t:parsedTypes)
+		for (Type t:_cache.keySet())
 				if (t.getName().equals(name))
 					return t;
 		
 		throw new TypeNotFoundException(_loc.get("no-type-for-name", name)
 			.toString());
 	}
+	
+	private void initializeDynamicClassConstructionEnvironment() {
+		if (throwAwayLoader == null) {
+			if (_log.isInfoEnabled())
+				_log.info(_loc.get("dynamic-enhancement").toString());
+			throwAwayLoader = new BCClassLoader(new Project());
+			enhancedLoader = new BCClassLoader(new Project());
+			MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
+			repos.setValidate(MetaDataRepository.VALIDATE_NONE);
+			repos.setSourceMode(MetaDataRepository.MODE_META);
+		}
+	}
+	
+	private Class generateEnhancedClass(Type type) {
+		initializeDynamicClassConstructionEnvironment();
+		String javaClassName = ImplHelper.getFullClassName(type);
+		if (enhancedLoader.getProject().containsClass(javaClassName)) {
+			return enhancedLoader.getProject().loadClass(javaClassName).getType();
+		}
+		_log.info(_loc.get("generate-dynamic-class", javaClassName));
+		BCClass bcls = throwAwayLoader.getProject().loadClass(javaClassName,throwAwayLoader);
+		TypeMapping throwAwayMapping = SDOMappingStrategy.decideStrategy(type, null);
+		
+		// clear the class
+		bcls.clearAttributes();
+		bcls.clearDeclaredFields();
+		bcls.clearDeclaredInterfaces();
+		bcls.clearDeclaredMethods();
+		
+		// annotate the class as @Entity
+		bcls.makePublic();
+		Annotations classAnns = bcls.getDeclaredRuntimeAnnotations(true);
+		Annotation entityAnno = classAnns.addAnnotation(Entity.class);
+		entityAnno.addProperty("name").setValue(type.getName());
+		
+		// set it for Java 5
+		bcls.setMajorVersion(49); // 49 bytecode spec = 1.5 source spec
+		bcls.setMinorVersion(0);
+		bcls.addDefaultConstructor();
+		
+		// add private field with bean-style get/set methods for each property
+		List properties = type.getProperties();
+		for (Object p : properties) {
+			Property property = (Property) p;
+			PropertyMapping pm = throwAwayMapping.getMapping(property);
+			BCField field = addField(bcls, pm.getFieldName(), pm.getFieldType(this));
+			pm.annotate(field);
+		}
+		Class enhancedClass = enhanceByteCode(bcls);
+		if (!isPersistenceCapable(enhancedClass))
+			throw new InternalException(_loc.get("enhancement-failed", toString(enhancedClass)).toString());
+		cache(type, enhancedClass);
+		return enhancedClass;
+	}
+
+	Class enhanceByteCode(BCClass bcls) {
+		_log.info(_loc.get("enhance-dynamic-class", bcls.getName()));
+		byte[] originalBytes = bcls.toByteArray();
+		BCClass ebcls = enhancedLoader.getProject().loadClass(new ByteArrayInputStream(originalBytes), 
+				enhancedLoader);
+		MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
+		PCEnhancer enhancer = new PCEnhancer(conf, ebcls, repos, enhancedLoader);
+		enhancer.run();
+		byte[] enhancedBytes = enhancer.getPCBytecode().toByteArray();
+		enhancedLoader.getProject().removeClass(ebcls);
+		ebcls = enhancedLoader.getProject().loadClass(new ByteArrayInputStream(enhancedBytes), 
+				enhancedLoader);
+		return reloadClass(ebcls);
+	}
+
+	Class reloadClass(BCClass bcls) {
+		write(bcls);
+		try {
+			return Class.forName(bcls.getName());
+		} catch (ClassNotFoundException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+	
+	void write(BCClass bcls) {
+		File classFile = getClassFile(bcls);
+		classFile.deleteOnExit();
+		if (_log.isInfoEnabled()) {
+			_log.info(_loc.get("write-class", classFile.getAbsolutePath()).toString());
+		}
+		try {
+			bcls.write(classFile);
+		} catch (IOException e) {
+			throw new UserException(e);
+		}
+	}
+
+	File getClassFile(BCClass bcls) {
+		File pkgdir = Files.getPackageFile(_root, bcls.getPackageName(), true);
+		return new File(pkgdir, bcls.getClassName() + ".class");
+	}
+	
+	void setRootDirectory(String rootPath) {
+		File file = new File(rootPath);
+		File rootDir = (file.isAbsolute()) ? file : new File(_root, rootPath);
+		if (rootDir.exists() && rootDir.isDirectory()) {
+				_root = rootDir;
+		} else {
+			_log.warn(_loc.get("wrong-root-dir", rootPath, _root.getAbsolutePath()));
+		}
+	}
+	
+    /**
+     * Add bean getters and setters.
+     */
+    private BCField addField (BCClass bc, String fieldName, Class fieldType) {
+		if (_log.isTraceEnabled())
+			_log.trace(_loc.get("dynamic-method", fieldName,fieldType).toString());
+        BCField field = bc.declareField(fieldName, fieldType);
+        field.setAccessFlags(Constants.ACCESS_PRIVATE);
+
+        // getter
+        String getterName = "get" + StringUtils.capitalize(fieldName);
+        BCMethod meth = bc.declareMethod(getterName, fieldType, null);
+        meth.makePublic();
+        Code code = meth.getCode(true);
+        code.aload().setThis();
+        code.getfield().setField(field);
+        code.xreturn().setType(fieldType);
+        code.calculateMaxStack();
+        code.calculateMaxLocals();
 
+        // setter
+        String setterName = "set" + StringUtils.capitalize(fieldName);
+        meth = bc.declareMethod(setterName, void.class, new Class[]{fieldType});
+        meth.makePublic();
+        code = meth.getCode(true);
+        code.aload().setThis();
+        code.xload().setParam(0).setType(fieldType);
+        code.putfield().setField(field);
+        code.vreturn();
+        code.calculateMaxStack();
+        code.calculateMaxLocals();
+        
+        return field;
+    }
+    
+    String toString(Class cls) {
+    	return (cls == null) ? "null" : cls + " loaded by " + cls.getClassLoader(); 
+    }
+    
+    boolean isPersistenceCapable(Class cls) {
+    	return PersistenceCapable.class.isAssignableFrom(cls);
+    }
 }

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOMetaDataFactory.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOMetaDataFactory.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOMetaDataFactory.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOMetaDataFactory.java Wed Aug 22 12:44:53 2007
@@ -28,6 +28,8 @@
 import org.apache.openjpa.lib.meta.ClassArgParser;
 import org.apache.openjpa.persistence.PersistenceMetaDataFactory;
 
+import commonj.sdo.Type;
+
 /**
  * A specialized MetaDataFactory to process XML Schema based SDO MetaModel.
  * <br>
@@ -51,7 +53,7 @@
 	private SDOTypeParser sdoTypeParser;
 	private Set<String> _typeNames = new HashSet<String>();
 	private SDOMappingRepository repos;
-
+	
 	@Override
 	public void setConfiguration(Configuration conf) {
 		super.setConfiguration(conf);
@@ -83,6 +85,15 @@
 		return resources;
 	}
 	
+	public String getGeneratedClassDirectory() {
+		return "";
+	}
+	
+	public void setGeneratedClassDirectory(String dir) {
+		repos.setRootDirectory(dir);
+	}
+
+	
 	@Override
 	public void endConfiguration() {
 		if (resources == null || resources.trim().length()==0)
@@ -96,24 +107,24 @@
 	
 	/**
 	 * Get the fully-qualified, persistent Java class names.
+	 * Invokes the parser for parsing XML Schema Definitions. 
+	 * The parsed SDO types are then resolved to Java classes by the Mapping
+	 * Repository, before returning from this method. 
 	 */
 	@Override
     public Set getPersistentTypeNames(boolean devpath, ClassLoader envLoader) {
     	if (resourceList == null || resourceList.isEmpty()) 
     		return _typeNames;
-    	for (String resource:resourceList) {
-    		String[] names = getSDOTypeParser().parseTypeNames(resource);
-    		for (String name:names)
-    			addPersistentTypeNames(name);
-    	}
+    	SDOTypeParser parser = getSDOTypeParser();
+    	List<String> tmpList = new ArrayList<String>(resourceList);
     	resourceList.clear();
-    	super.getPersistentTypeNames(devpath, envLoader);
+    	for (String resource:tmpList) {
+    		List<Type> types = parser.parseXSDResource(resource);
+    		for (Type type:types) {
+    			Class c = repos.getJavaClass(type, true);//(type, envLoader);
+    			_typeNames.add(c.getName());
+    		}
+    	}
     	return _typeNames;
     }
-    
-
-    public void addPersistentTypeNames(String name) {
-    	_typeNames.add(name);
-    }
-    
 }

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOTypeParser.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOTypeParser.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOTypeParser.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOTypeParser.java Wed Aug 22 12:44:53 2007
@@ -3,6 +3,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -10,10 +11,12 @@
 import java.util.Set;
 
 import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.meta.ClassArgParser;
 import org.apache.openjpa.lib.util.Localizer;
 
+import commonj.sdo.Property;
 import commonj.sdo.Type;
 import commonj.sdo.helper.XSDHelper;
 
@@ -24,35 +27,24 @@
  * @since 0.1.0
  */
 public class SDOTypeParser extends ClassArgParser {
-	private static final Localizer _loc = Localizer
-		.forPackage(SDOTypeParser.class);
-	private final SDOMappingRepository repos;
-	private static final String[] EMPTY_STRING = {};
+	private static final Localizer _loc = Localizer.forPackage
+		(SDOTypeParser.class);
+	private static Map<String, List<Type>> parsedResource = 
+		new HashMap<String, List<Type>>();
 	private Log _log;	
-	private static Map<String, List<Type>> parsedResource = new HashMap<String, List<Type>>();
 	
 	/**
 	 * Supply configuration.
 	 */
 	SDOTypeParser(OpenJPAConfiguration conf) {
 		_log = conf.getLog(OpenJPAConfiguration.LOG_METADATA);
-		SDOMetaDataFactory mdf = (SDOMetaDataFactory)conf
-			.getMetaDataRepositoryInstance().getMetaDataFactory();
-		repos = mdf.getSDOMappingRepository();
 	}
 	
-	/**
-	 * Parse the given resource if it has not been parsed already.
-	 * If resource is null or does not end with ".xsd", return empty array.
-	 * 
-	 */
-	public String[] parseTypeNames(String resource) {
-		if (resource==null || !resource.endsWith(".xsd"))
-			return super.parseTypeNames(resource);
+	public List<Type> parseXSDResource(String resource) {
 		if (parsedResource.containsKey(resource)) {
 			if (_log.isWarnEnabled())
 				_log.warn(_loc.get("repeat-parse", resource));
-			return resolveTypes(parsedResource.get(resource));
+			return parsedResource.get(resource);
 		}
 		
 		_log.info(_loc.get("parse-xml-schema", resource));
@@ -62,10 +54,12 @@
 			if (_log.isWarnEnabled()) {
 				_log.warn(_loc.get("xsd-not-found", resource).toString());
 			}
-			return EMPTY_STRING;
+			return Collections.EMPTY_LIST;
 		}
 		List<Type> userTypes = new ArrayList<Type>();
 		try {
+			if (XSDHelper.INSTANCE==null)
+				throw new RuntimeException("no-sdo-provider");
 			List types = XSDHelper.INSTANCE.define(xsdInputStream, null);
 			for (Object t : types) {
 				if (t instanceof Type == false)
@@ -84,22 +78,42 @@
 				//ignore
 			}
 		}
-		return resolveTypes(userTypes);
+		return userTypes;
+		
 	}
 	
-	String[] resolveTypes(List<Type> types) {
+	/**
+	 * Parse the given resource if it has not been parsed already.
+	 * If resource is null or does not end with ".xsd", delegate to superclass
+	 * for processing.
+	 * 
+	 */
+	@Override
+	public String[] parseTypeNames(String resource) {
+		if (resource==null || !resource.endsWith(".xsd"))
+			return super.parseTypeNames(resource);
+		return toNames(parseXSDResource(resource));
+	}
+	
+	String[] toNames(List<Type> types) {
 		List<String> names = new ArrayList<String>();
 		for (Type type:types) {
 			String className = ImplHelper.getFullClassName(type); 
-			try {
-				Class cls = Class.forName(className);
-				repos.cache(type, cls);
-				names.add(className);
-			} catch (ClassNotFoundException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
+			names.add(className);
 		}
 		return names.toArray(new String[names.size()]);
+	}
+	
+	/**
+	 * Find a type of given name from all the types parsed from resources.
+	 */
+	public Type findType(String name) {
+		for (List<Type> types:parsedResource.values()) {
+			for (Type type:types) {
+				if (type.getName().equals(name))
+					return type;
+			}
+		}
+		return null;
 	}
 }

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOTypeRepository.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOTypeRepository.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOTypeRepository.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/SDOTypeRepository.java Wed Aug 22 12:44:53 2007
@@ -252,7 +252,6 @@
 				addMappingAnnotation(property, bcfield);
 			}
 		}
-		factory.addPersistentTypeNames(javaClassName);
 		return enhanceByteCode(bcls);
 	}
 

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/AbstractPropertyMapping.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/AbstractPropertyMapping.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/AbstractPropertyMapping.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/AbstractPropertyMapping.java Wed Aug 22 12:44:53 2007
@@ -32,27 +32,35 @@
  * @since 0.2.0
  */
 public abstract class AbstractPropertyMapping implements PropertyMapping {
+	protected final TypeMapping owner;
 	protected final Property property;
 	protected final FieldMapping fm;
 	protected Method getter;
 	protected Method setter;
 	protected static final Object[] NULL_ARGS = new Object[]{};
 	
-	protected AbstractPropertyMapping(Property property, FieldMapping fm) {
+	protected AbstractPropertyMapping(TypeMapping owner, 
+			Property property, FieldMapping fm) {
+		this.owner = owner;
 		this.property = property;
 		this.fm = fm;
 		if (fm != null) { // runtime
-			Class cls = fm.getDeclaringType();
-			getter = Reflection.findGetter(cls, fm.getName(), true);
-			setter = Reflection.findSetter(cls, fm.getName(), true);
+			resolve(fm);
 		}
 	}
-	
+
 	public final Property getProperty() {
 		return property;
 	}
 	
 	public String getFieldName() {
 		return property.getName();
+	}
+	
+	public void resolve(FieldMapping fm) {
+		if (getter != null) return;
+		Class cls = fm.getDeclaringType();
+		getter = Reflection.findGetter(cls, fm.getName(), true);
+		setter = Reflection.findSetter(cls, fm.getName(), true);
 	}
 }

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/IdenticalTypeMapping.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/IdenticalTypeMapping.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/IdenticalTypeMapping.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/IdenticalTypeMapping.java Wed Aug 22 12:44:53 2007
@@ -25,6 +25,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.FieldMapping;
+import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.sdo.ImplHelper;
 
 import commonj.sdo.Property;
@@ -38,27 +39,48 @@
  */
 public class IdenticalTypeMapping implements TypeMapping {
 	protected final Type type;
-	protected final Class cls;
+	protected Class cls;
 	protected IdentityMapping identityMapping;
 	protected VersionMapping versionMapping;
+	private boolean resolved = false;
+	private int idType;
 	
 	protected SDOMappingStrategy mappingStrategy = new SDOMappingStrategy();
 	
 	protected Map<Property, PropertyMapping> _propertyMappings = 
 		new HashMap<Property, PropertyMapping>();
 	
-	public IdenticalTypeMapping(Type type, ClassMapping clsMeta) {
+	public IdenticalTypeMapping(Type type, Class cls) {
 		this.type = type;
-		this.cls  = (clsMeta==null) ? null : clsMeta.getDescribedType();
+		this.cls  = cls;//(clsMeta==null) ? null : clsMeta.getDescribedType();
+		this.idType = (ImplHelper.getIdentityProperty(type) == null) ? 
+				ClassMetaData.ID_DATASTORE : ClassMetaData.ID_APPLICATION;
+		
 		List properties = type.getProperties();
 		for (Object p:properties) {
 			Property property = (Property)p;
-			FieldMapping field = (clsMeta==null) ? null : 
-				clsMeta.getFieldMapping(property.getName());
-			addMapping(property, field);
+//			FieldMapping field = (clsMeta==null) ? null : 
+//				clsMeta.getFieldMapping(property.getName());
+			addMapping(property, null);
 		}
 	}
 	
+	public boolean isResolved() {
+		return resolved;
+	}
+	
+	public void resolve(ClassMapping cm) {
+		if (resolved) return;
+		cls = cm.getDescribedType();
+		List properties = type.getProperties();
+		for (Object p:properties) {
+			Property property = (Property)p;
+			FieldMapping fm = cm.getFieldMapping(property.getName());
+			getMapping(property).resolve(fm);
+		}
+		resolved = true;
+	}
+	
 	public Type getType() {
 		return type;
 	}
@@ -66,7 +88,7 @@
 	PropertyMapping addMapping(Property p, FieldMapping field) {
 		if (p.getContainingType() != type)
 			throw new IllegalArgumentException(p.getName());
-		PropertyMapping mapping = SDOMappingStrategy.decideStrategy(p, field);
+		PropertyMapping mapping = SDOMappingStrategy.decideStrategy(this, p, field);
 		if (mapping instanceof IdentityMapping)
 			setIdentityMapping((IdentityMapping)mapping);
 		if (mapping instanceof VersionMapping) 
@@ -76,6 +98,8 @@
 	}
 	
 	public PropertyMapping getMapping(Property p) {
+		if (!_propertyMappings.containsKey(p))
+			throw new RuntimeException("No mapping for " + p.getName());
 		return _propertyMappings.get(p);
 	}
 	

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/IdentityMapping.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/IdentityMapping.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/IdentityMapping.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/IdentityMapping.java Wed Aug 22 12:44:53 2007
@@ -18,8 +18,13 @@
  */
 package org.apache.openjpa.sdo.mapping;
 
+import javax.persistence.Id;
+
 import org.apache.openjpa.jdbc.meta.FieldMapping;
 
+import serp.bytecode.Annotations;
+import serp.bytecode.BCField;
+
 import commonj.sdo.Property;
 
 /**
@@ -30,16 +35,21 @@
  */
 public class IdentityMapping extends PrimitiveMapping {
 
-	IdentityMapping(Property property, FieldMapping fm) {
-		super(property, fm);
+	IdentityMapping(TypeMapping tm, Property property, FieldMapping fm) {
+		super(tm, property, fm);
 	}
 	
 	public String getName() {
 		return "IdentityMapping";
 	}
 	
-	public String[] getAnnotations() {
-		return new String[] {"@Id", "@GeneratedValue"};
+	public String[] getAnnotationStrings() {
+		return new String[] {"@Id"};
+	}
+	
+	public void annotate(BCField field) {
+		Annotations annos = field.getDeclaredRuntimeAnnotations(true);
+		annos.addAnnotation(Id.class);
+//		annos.addAnnotation(GeneratedValue.class);
 	}
-
 }

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PrimitiveListMapping.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PrimitiveListMapping.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PrimitiveListMapping.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PrimitiveListMapping.java Wed Aug 22 12:44:53 2007
@@ -18,10 +18,14 @@
  */
 package org.apache.openjpa.sdo.mapping;
 
+import java.util.List;
+
 import org.apache.openjpa.jdbc.meta.FieldMapping;
 import org.apache.openjpa.sdo.ImplHelper;
+import org.apache.openjpa.sdo.SDOMappingRepository;
 
 import commonj.sdo.Property;
+import commonj.sdo.Type;
 
 /**
  * Maps Primitive, many-valued Property.
@@ -30,8 +34,8 @@
  * @since 0.2.0
  */
 public class PrimitiveListMapping extends PrimitiveMapping {
-	PrimitiveListMapping(Property p, FieldMapping fmd) {
-		super(p, fmd);
+	PrimitiveListMapping(TypeMapping tm, Property p, FieldMapping fmd) {
+		super(tm, p, fmd);
 	}
 
 	public String getName() {
@@ -39,8 +43,14 @@
 	}
 	
 	public String getFieldTypeName() {
-		return "java.util.List<" + 
-			ImplHelper.getComponentType(property.getType()).
-			getInstanceClass().getName() + ">";
+		Type elementType = ImplHelper.getComponentType(property.getType());
+		if (elementType==null) 
+			elementType = property.getType();
+		return  "java.util.List<" + elementType.getInstanceClass().getName() + ">";
+	}
+	
+	public Class getFieldType(SDOMappingRepository repos) {
+//		Class componentType = ImplHelper.getComponentType(property.getType()).getInstanceClass();
+		return List.class;
 	}
 }

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PrimitiveMapping.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PrimitiveMapping.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PrimitiveMapping.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PrimitiveMapping.java Wed Aug 22 12:44:53 2007
@@ -18,8 +18,15 @@
  */
 package org.apache.openjpa.sdo.mapping;
 
+import javax.persistence.Basic;
+
 import org.apache.openjpa.jdbc.meta.FieldMapping;
 import org.apache.openjpa.sdo.SDOInstanceMapping;
+import org.apache.openjpa.sdo.SDOMappingRepository;
+
+import serp.bytecode.Annotation;
+import serp.bytecode.Annotations;
+import serp.bytecode.BCField;
 
 import commonj.sdo.DataObject;
 import commonj.sdo.Property;
@@ -32,8 +39,8 @@
  */
 public class PrimitiveMapping extends AbstractPropertyMapping {
 	
-	PrimitiveMapping(Property p, FieldMapping fm) {
-		super(p, fm);
+	PrimitiveMapping(TypeMapping tm, Property p, FieldMapping fm) {
+		super(tm, p, fm);
 	}
 	
 	public String getName() {
@@ -44,8 +51,17 @@
 		return property.getType().getInstanceClass().getName();
 	}
 	
-	public String[] getAnnotations() {
+	public Class getFieldType(SDOMappingRepository repos) {
+		return property.getType().getInstanceClass();
+	}
+	
+	public String[] getAnnotationStrings() {
 		return new String[]{};
+	}
+	
+	public void annotate(BCField field) {
+		Annotations annos = field.getDeclaredRuntimeAnnotations(true);
+		annos.addAnnotation(Basic.class);
 	}
 	
 	public DataObject populateDataObject(DataObject target, Object source, 

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PropertyMapping.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PropertyMapping.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PropertyMapping.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/PropertyMapping.java Wed Aug 22 12:44:53 2007
@@ -18,7 +18,11 @@
  */
 package org.apache.openjpa.sdo.mapping;
 
+import org.apache.openjpa.jdbc.meta.FieldMapping;
 import org.apache.openjpa.sdo.SDOInstanceMapping;
+import org.apache.openjpa.sdo.SDOMappingRepository;
+
+import serp.bytecode.BCField;
 
 import commonj.sdo.DataObject;
 import commonj.sdo.Property;
@@ -31,6 +35,7 @@
  * @since 0.2.0
  */
 public interface PropertyMapping  {
+	public void resolve(FieldMapping fm);
 	/**
 	 * Get the Property being mapped by this receiver.
 	 */
@@ -53,10 +58,14 @@
 	 */
 	public String getFieldTypeName();
 	
+	public Class getFieldType(SDOMappingRepository repos);
+	
 	/**
 	 * Gets the persistent annotations for the target Java field.
 	 */
-	public String[] getAnnotations();
+	public String[] getAnnotationStrings();
+	
+	public void annotate(BCField field);
 	
 	/**
 	 * Populate the given <code>target</code> DataObject from the field value

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/RelationListMapping.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/RelationListMapping.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/RelationListMapping.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/RelationListMapping.java Wed Aug 22 12:44:53 2007
@@ -21,9 +21,17 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.persistence.OneToMany;
+import javax.persistence.Version;
+
 import org.apache.openjpa.jdbc.meta.FieldMapping;
+import org.apache.openjpa.persistence.ElementType;
 import org.apache.openjpa.sdo.ImplHelper;
 import org.apache.openjpa.sdo.SDOInstanceMapping;
+import org.apache.openjpa.sdo.SDOMappingRepository;
+
+import serp.bytecode.Annotations;
+import serp.bytecode.BCField;
 
 import commonj.sdo.DataObject;
 import commonj.sdo.Property;
@@ -38,8 +46,8 @@
 public class RelationListMapping extends RelationMapping {
 	Type componentType;
 	Property componentProperty;
-	RelationListMapping(Property p, FieldMapping fm) {
-		super(p, fm);
+	RelationListMapping(TypeMapping tm, Property p, FieldMapping fm) {
+		super(tm, p, fm);
 		componentProperty = ImplHelper.getComponentProperty(property.getType());
 		componentType = componentProperty.getType();
 	}
@@ -53,8 +61,19 @@
 		return "java.util.List<"+javaClassName+">";
 	}
 	
-	public String[] getAnnotations() {
+	public Class getFieldType(SDOMappingRepository repos) {
+		return List.class;
+	}
+
+	
+	public String[] getAnnotationStrings() {
 		return new String[] {"@OneToMany"};
+	}
+
+	public void annotate(BCField field) {
+		Annotations annos = field.getDeclaredRuntimeAnnotations(true);
+		annos.addAnnotation(OneToMany.class);
+//		annos.addAnnotation(ElementType.class).setValue(arg0)
 	}
 
 	public DataObject populateDataObject(DataObject target, Object source, 

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/RelationMapping.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/RelationMapping.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/RelationMapping.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/RelationMapping.java Wed Aug 22 12:44:53 2007
@@ -18,9 +18,16 @@
  */
 package org.apache.openjpa.sdo.mapping;
 
+import javax.persistence.OneToOne;
+import javax.persistence.Version;
+
 import org.apache.openjpa.jdbc.meta.FieldMapping;
 import org.apache.openjpa.sdo.ImplHelper;
 import org.apache.openjpa.sdo.SDOInstanceMapping;
+import org.apache.openjpa.sdo.SDOMappingRepository;
+
+import serp.bytecode.Annotations;
+import serp.bytecode.BCField;
 
 import commonj.sdo.DataObject;
 import commonj.sdo.Property;
@@ -33,8 +40,8 @@
  */
 public class RelationMapping extends AbstractPropertyMapping {
 	
-	RelationMapping(Property p, FieldMapping fm) {
-		super(p, fm);
+	RelationMapping(TypeMapping tm, Property p, FieldMapping fm) {
+		super(tm, p, fm);
 	}
 	
 	public String getName() {
@@ -45,8 +52,17 @@
 		return ImplHelper.getFullClassName(property.getType());
 	}
 	
-	public String[] getAnnotations() {
+	public Class getFieldType(SDOMappingRepository repos) {
+		return repos.getJavaClass(property.getType(), true);
+	}
+	
+	public String[] getAnnotationStrings() {
 		return new String[] {"@OneToOne"};
+	}
+	
+	public void annotate(BCField field) {
+		Annotations annos = field.getDeclaredRuntimeAnnotations(true);
+		annos.addAnnotation(OneToOne.class);
 	}
 
 	public DataObject populateDataObject(DataObject target, Object source, 

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/SDOMappingStrategy.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/SDOMappingStrategy.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/SDOMappingStrategy.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/SDOMappingStrategy.java Wed Aug 22 12:44:53 2007
@@ -18,7 +18,6 @@
  */
 package org.apache.openjpa.sdo.mapping;
 
-import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.FieldMapping;
 import org.apache.openjpa.sdo.ImplHelper;
 
@@ -42,8 +41,8 @@
 	 * 
 	 * @return the mapping to be used for the given Type.
 	 */
-	public static TypeMapping decideStrategy(Type type, ClassMapping cmd) {
-		return new IdenticalTypeMapping(type, cmd);
+	public static TypeMapping decideStrategy(Type type, Class cls) {
+		return new IdenticalTypeMapping(type, cls);
 	}
 	
 	/**
@@ -57,30 +56,30 @@
 	 * @return the mapping to be used for the given Property.
 	 * 
 	 */
-	public static PropertyMapping decideStrategy(Property p, FieldMapping fmd) {
+	public static PropertyMapping decideStrategy(TypeMapping tm, Property p, FieldMapping fmd) {
 		if (ImplHelper.isIdentity(p))
-			return new IdentityMapping(p, fmd);
+			return new IdentityMapping(tm, p, fmd);
 		if (ImplHelper.isVersion(p))
-			return new VersionMapping(p, fmd);
+			return new VersionMapping(tm, p, fmd);
 
 		if (p.getType().isDataType()) {
 			if (p.isMany()) {
-				return new PrimitiveListMapping(p, fmd);
+				return new PrimitiveListMapping(tm, p, fmd);
 			} else {
-				return new PrimitiveMapping(p, fmd);
+				return new PrimitiveMapping(tm, p, fmd);
 			}
 		}
 		if (ImplHelper.isContainer(p.getType())) {
 			Type componentType = ImplHelper.getComponentType(p.getType());
 			if (componentType.isDataType())
-				return new PrimitiveListMapping(p, fmd);
+				return new PrimitiveListMapping(tm, p, fmd);
 			else
-				return new RelationListMapping(p, fmd);
+				return new RelationListMapping(tm, p, fmd);
 		}
 		if (p.isMany()) {
-			return new RelationListMapping(p, fmd);
+			return new RelationListMapping(tm, p, fmd);
 		} else {
-			return new RelationMapping(p, fmd);
+			return new RelationMapping(tm, p, fmd);
 		}
 	}
 }

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/TypeMapping.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/TypeMapping.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/TypeMapping.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/TypeMapping.java Wed Aug 22 12:44:53 2007
@@ -18,6 +18,9 @@
  */
 package org.apache.openjpa.sdo.mapping;
 
+import org.apache.openjpa.jdbc.meta.ClassMapping;
+import org.apache.openjpa.sdo.SDOMappingRepository;
+
 import commonj.sdo.Property;
 import commonj.sdo.Type;
 
@@ -25,11 +28,22 @@
  * Defines the protocol of mapping a SDO Type to a Java Class.
  * 
  * @author Pinaki Poddar
+ * @since 0.2.0
  *
  */
 public interface TypeMapping {
 	/**
-	 * Gets the type being mapped by this receiver.
+	 * Resolve this mapping against the database mapping.
+	 */
+	public void resolve(ClassMapping cm);
+	
+	/**
+	 * Affirm if this mapping is resloved.
+	 */
+	public boolean isResolved();
+	
+	/**
+	 * Gets the SDO type being mapped by this receiver.
 	 */
 	public Type getType();
 	

Modified: labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/VersionMapping.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/VersionMapping.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/VersionMapping.java (original)
+++ labs/fluid/src/main/java/org/apache/openjpa/sdo/mapping/VersionMapping.java Wed Aug 22 12:44:53 2007
@@ -18,8 +18,15 @@
  */
 package org.apache.openjpa.sdo.mapping;
 
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Version;
+
 import org.apache.openjpa.jdbc.meta.FieldMapping;
 
+import serp.bytecode.Annotations;
+import serp.bytecode.BCField;
+
 import commonj.sdo.Property;
 
 /**
@@ -30,19 +37,24 @@
  */
 public class VersionMapping extends PrimitiveMapping {
 
-	VersionMapping(Property property, FieldMapping fm) {
-		super(property, fm);
+	VersionMapping(TypeMapping tm, Property property, FieldMapping fm) {
+		super(tm, property, fm);
 	}
 
 	public String getName() {
 		return "VersionMapping";
 	}
 	
-	public String[] getAnnotations() {
+	public String[] getAnnotationStrings() {
 		return new String[] {"@Version"};
 	}
 
 	public String getFieldTypeName() {
 		return "int";
+	}
+
+	public void annotate(BCField field) {
+		Annotations annos = field.getDeclaredRuntimeAnnotations(true);
+		annos.addAnnotation(Version.class);
 	}
 }

Modified: labs/fluid/src/main/resources/org/apache/openjpa/sdo/localizer.properties
URL: http://svn.apache.org/viewvc/labs/fluid/src/main/resources/org/apache/openjpa/sdo/localizer.properties?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/main/resources/org/apache/openjpa/sdo/localizer.properties (original)
+++ labs/fluid/src/main/resources/org/apache/openjpa/sdo/localizer.properties Wed Aug 22 12:44:53 2007
@@ -1,13 +1,23 @@
-cache-sdo-type: "{0}" cached SDO type "{1}" mapped to Java class "{2}" loaded \
-	by "{3}"
-cache-unenhanced: Class "{0}" loaded by "{1}" is not enhanced and hence can \
-	not be cached 
+type-mapping-new: Creating new SDO Type Mapping for "{0}" mapped to "{1}"
+type-mapping-resolve: Resolving SDO Type Mapping for "{0}" mapped to "{1}"
+resolve-mapping-failed: No cached metadata found for "{0}" in "{1}"
+
+cache-replace-sdo-type: Replaced association of SDO Type "{0}" by "{1}" \
+	(previously was "{2}")
+cache-sdo-type: Caching SDO type "{0}" mapped to "{1}"
+cache-unenhanced: Can not cache unenhanced "{0}"
+
+generate-dynamic-class: Generating dynamic Java class "{0}" 
 enhance-dynamic-class: Enhancing dynamic Java class "{0}" 
 found-enhanced-cls:Enhanced class "{1}" loaded by "{2}" exists for SDO type "{0}" 
+
 no-class-for-type: No Java class can be found or created for SDO Type "{0}"
-no-type-for-class: No SDO Type can be found for Java class "{0}" loaded \
-	by "{1}"
+no-type-for-class: No SDO Type can be found for "{0}"
 no-type-for-name: No SDO Type named "{0}" can be found	
+
+dynamic-enhancement: Initializing for dynamic construction and enhancement of \
+	Java classes for SDO Types
+dynamic-method: Creating getter/setter methods for field "{1}" "{0}" 
 parse-xml-schema: Parsing XML Schema "{0}"
 register-sdo: Dynamic class "{0}" is loaded by "{1}"
 sdo-repos-init: Dynamic Java classes will be written to "{0}". Make sure that \
@@ -26,4 +36,5 @@
 container-type-not-converted: No conversion for SDO container Type "{0}"
 mapping-type: Mapping SDO Type "{0}" to Java Class "{1}"
 mapping-property: Mapping SDO Property "{0}" to a Java field of type "{1}" \
-	using "{2}"
\ No newline at end of file
+	using "{2}"
+no-sdo-provider: Can not find any SDO Implementation in current classpath. 
\ No newline at end of file

Modified: labs/fluid/src/test/java/example/basic/TestCRUD.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/test/java/example/basic/TestCRUD.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/test/java/example/basic/TestCRUD.java (original)
+++ labs/fluid/src/test/java/example/basic/TestCRUD.java Wed Aug 22 12:44:53 2007
@@ -97,11 +97,11 @@
 			assertNotNull(ImplHelper.getIdValue(dataObject));
 			
 			dataObject.setString("firstName", "Ron");
-			em.begin();
+			em.getTransaction().begin();
 			DataObject merged = em.merge(dataObject);
 			int v1 = ImplHelper.getVersion(merged);
 			assertTrue(v1>v0);
-			em.commit();
+			em.getTransaction().commit();
 			assertEquals("Ron", merged.getString("firstName"));
 			int after = count("Person");
 			assertEquals(before, after);
@@ -124,9 +124,9 @@
 		for (Object o : result) {
 			int before = count("Person");
 			DataObject dataObject = (DataObject) o;
-			em.begin();
+			em.getTransaction().begin();
 			em.remove(dataObject);
-			em.commit();
+			em.getTransaction().commit();
 			int after = count("Person");
 			assertEquals(before-1, after);
 		}

Modified: labs/fluid/src/test/java/example/basic/TestRelation.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/test/java/example/basic/TestRelation.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/test/java/example/basic/TestRelation.java (original)
+++ labs/fluid/src/test/java/example/basic/TestRelation.java Wed Aug 22 12:44:53 2007
@@ -83,9 +83,9 @@
 		for (DataObject dataObject : result) {
 			int before = count("USAddress");
 			dataObject.getDataObject("billTo").setString("name", "John Doe");
-			em.begin();
+			em.getTransaction().begin();
 			DataObject merged = em.merge(dataObject);
-			em.commit();
+			em.getTransaction().commit();
 			String changedName = merged.getDataObject("billTo").getString("name");
 			assertEquals("John Doe", changedName);
 			int after = count("USAddress");
@@ -136,9 +136,9 @@
 		for (Object o : result) {
 			int before = count("USAddress");
 			DataObject dataObject = (DataObject) o;
-			em.begin();
+			em.getTransaction().begin();
 			em.remove(dataObject);
-			em.commit();
+			em.getTransaction().commit();
 			int after = count("USAddress");
 			assertEquals(before-2, after); // 2 address /PurchaseOrder
 		}

Modified: labs/fluid/src/test/java/org/apache/openjpa/sdo/TestSDO.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/test/java/org/apache/openjpa/sdo/TestSDO.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/test/java/org/apache/openjpa/sdo/TestSDO.java (original)
+++ labs/fluid/src/test/java/org/apache/openjpa/sdo/TestSDO.java Wed Aug 22 12:44:53 2007
@@ -52,7 +52,7 @@
 	public void testIdentityType() {
 		Type poType = getType("PurchaseOrderType");
 		assertNotNull(poType);
-		Property id2 = ImplHelper.getIdentity(poType);
+		Property id2 = ImplHelper.getIdentityProperty(poType);
 		assertNotNull(id2);
 		assertTrue(ImplHelper.isIdentity(id2));
 	}

Modified: labs/fluid/src/test/java/test/common/AbstractSDOTest.java
URL: http://svn.apache.org/viewvc/labs/fluid/src/test/java/test/common/AbstractSDOTest.java?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/test/java/test/common/AbstractSDOTest.java (original)
+++ labs/fluid/src/test/java/test/common/AbstractSDOTest.java Wed Aug 22 12:44:53 2007
@@ -80,8 +80,8 @@
 	 */
 	public int count(String alias) {
 		OpenJPAEntityManager em = emf.createEntityManager();
-		Query query = em.createQuery("SELECT COUNT(o) FROM " + alias + " o");
-		return ((Long)query.getSingleResult()).intValue();
+		Query query = em.createQuery("SELECT o FROM " + alias + " o");
+		return query.getResultList().size();
 	}
 	
 	/**

Modified: labs/fluid/src/test/resources/META-INF/books.xsd
URL: http://svn.apache.org/viewvc/labs/fluid/src/test/resources/META-INF/books.xsd?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/test/resources/META-INF/books.xsd (original)
+++ labs/fluid/src/test/resources/META-INF/books.xsd Wed Aug 22 12:44:53 2007
@@ -16,6 +16,7 @@
         </xs:sequence>
       </xs:complexType>
     </xs:element>
+    <xs:element name="authorNames" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
     <xs:element name="description" type="xs:string"  minOccurs="0"/>
     <xs:element name="promotion">
        <xs:complexType>

Modified: labs/fluid/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/labs/fluid/src/test/resources/META-INF/persistence.xml?rev=568737&r1=568736&r2=568737&view=diff
==============================================================================
--- labs/fluid/src/test/resources/META-INF/persistence.xml (original)
+++ labs/fluid/src/test/resources/META-INF/persistence.xml Wed Aug 22 12:44:53 2007
@@ -4,14 +4,14 @@
 
 		<properties>
 			<property name="openjpa.EntityManagerFactory" value="sdo"/>
-			<property name="openjpa.MetaDataFactory" value="sdo(Resources=META-INF/person.xsd;META-INF/po.xsd)"/>
+			<property name="openjpa.MetaDataFactory" value="sdo(Resources=META-INF/person.xsd)"/>
 			<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
 			<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost/SDO2"/>
 			<property name="openjpa.ConnectionUserName" value="root"/>
 			<property name="openjpa.ConnectionPassword" value="hello"/>
 			<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
    			<property name="openjpa.QueryCompilationCache" value="false"/>
-   			<property name="openjpa.Log" value="DefaultLevel=INFO, SQL=TRACE"/>
+   			<property name="openjpa.Log" value="DefaultLevel=TRACE, SQL=TRACE, Query=TRACE"/>
   			<property name="openjpa.BrokerImpl" value="non-finalizing"/>
    			
       	</properties>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message