Hibernate SVN: r10529 - in trunk/HibernateExt/tools/src: java/org/hibernate java/org/hibernate/cfg java/org/hibernate/cfg/reveng java/org/hibernate/tool/hbm2x java/org/hibernate/tool/hbm2x/pojo test/org/hibernate/tool/test/jdbc2cfg testsupport
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-09-25 12:14:29 -0400 (Mon, 25 Sep 2006)
New Revision: 10529
Added:
trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/MetaAttributeBinder.java
Modified:
trunk/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java
trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java
trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DelegatingReverseEngineeringStrategy.java
trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideBinder.java
trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java
trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java
trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableFilter.java
trunk/HibernateExt/tools/src/java/org/hibernate/hibernate-reverse-engineering-3.0.dtd
trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/MetaAttributeHelper.java
trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/overridetest.reveng.xml
trunk/HibernateExt/tools/src/testsupport/NoopReverseEngineeringStrategy.java
Log:
HBX-575 meta support in reveng.xml
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -41,6 +41,7 @@
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
+import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value;
@@ -152,6 +153,9 @@
rc.setProxyInterfaceName( rc.getEntityName() ); // TODO: configurable ?
rc.setLazy(true);
+ rc.setMetaAttributes( safeMeta(revengStrategy.tableToMetaAttributes( tableIdentifier )) );
+
+
rc.setDiscriminatorValue( rc.getEntityName() );
rc.setTable(table);
try {
@@ -176,6 +180,14 @@
}
+ private Map safeMeta(Map map) {
+ if(map==null) {
+ return new HashMap();
+ } else {
+ return map;
+ }
+ }
+
// bind collections.
private void bindIncomingForeignKeys(PersistentClass rc, Set processed, List foreignKeys, Mapping mapping) {
if(foreignKeys!=null) {
@@ -217,7 +229,7 @@
processedColumns.add(fkcolumn);
}
value.setFetchMode(FetchMode.SELECT);
- return makeProperty(propertyName, value, true, true, value.getFetchMode()!=FetchMode.JOIN, null, null);
+ return makeProperty(TableIdentifier.create( table ), propertyName, value, true, true, value.getFetchMode()!=FetchMode.JOIN, null, null);
}
/**
@@ -306,7 +318,7 @@
mappings.addCollection(collection);
- return makeProperty(StringHelper.unqualify( collection.getRole() ), collection, true, true, true, "all", null); // TODO: cascade isn't all by default
+ return makeProperty(TableIdentifier.create( rc.getTable() ), StringHelper.unqualify( collection.getRole() ), collection, true, true, true, "all", null); // TODO: cascade isn't all by default
}
@@ -443,7 +455,7 @@
}
- Property property = makeProperty(makeUnique(rc,idPropertyname), id, true, true, false, null, null);
+ Property property = makeProperty(tableIdentifier, makeUnique(rc,idPropertyname), id, true, true, false, null, null);
rc.setIdentifierProperty(property);
rc.setIdentifier(id);
@@ -569,7 +581,7 @@
SimpleValue value = bindColumnToSimpleValue( table, column, mapping, false );
- return makeProperty(propertyName, value, true, true, false, null, null);
+ return makeProperty(TableIdentifier.create( table ), propertyName, value, true, true, false, null, null);
}
private SimpleValue bindColumnToSimpleValue(Table table, Column column, Mapping mapping, boolean generatedIdentifier) {
@@ -799,7 +811,7 @@
}
}
- private static Property makeProperty(String propertyName, Value value, boolean insertable, boolean updatable, boolean lazy, String cascade, String propertyAccessorName) {
+ private Property makeProperty(TableIdentifier table, String propertyName, Value value, boolean insertable, boolean updatable, boolean lazy, String cascade, String propertyAccessorName) {
log.debug("Building property " + propertyName);
Property prop = new Property();
prop.setName(propertyName);
@@ -808,12 +820,25 @@
prop.setUpdateable(updatable);
prop.setLazy(lazy);
prop.setCascade(cascade==null?"none":cascade);
- prop.setPropertyAccessorName(propertyAccessorName==null?"property":propertyAccessorName);
- prop.setMetaAttributes(Collections.EMPTY_MAP);
+ prop.setPropertyAccessorName(propertyAccessorName==null?"property":propertyAccessorName);
+ bindMeta(prop, table);
return prop;
}
+ private Property bindMeta(Property property, TableIdentifier identifier) {
+ Iterator columnIterator = property.getValue().getColumnIterator();
+ while(columnIterator.hasNext()) {
+ Column col = (Column) columnIterator.next();
+
+ Map map = revengStrategy.columnToMetaAttributes( identifier, col.getName() );
+ if(map!=null) { // TODO: merge from each column ?
+ property.setMetaAttributes( map );
+ }
+ }
+
+ return property;
+ }
/**
* @param pkc
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -6,6 +6,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -15,7 +16,6 @@
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.ForeignKey;
-import org.hibernate.mapping.PrimaryKey;
import org.hibernate.mapping.Table;
import org.hibernate.util.StringHelper;
@@ -249,5 +249,13 @@
}
return propertyName;
}
+
+ public Map tableToMetaAttributes(TableIdentifier tableIdentifier) {
+ return null;
+ }
+
+ public Map columnToMetaAttributes(TableIdentifier identifier, String column) {
+ return null;
+ }
}
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DelegatingReverseEngineeringStrategy.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DelegatingReverseEngineeringStrategy.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DelegatingReverseEngineeringStrategy.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -1,6 +1,7 @@
package org.hibernate.cfg.reveng;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.hibernate.connection.ConnectionProvider;
@@ -119,5 +120,13 @@
public String foreignKeyToManyToManyName(ForeignKey fromKey, TableIdentifier middleTable, ForeignKey toKey, boolean uniqueReference) {
return delegate==null?null:delegate.foreignKeyToManyToManyName( fromKey, middleTable, toKey, uniqueReference );
}
+
+ public Map tableToMetaAttributes(TableIdentifier tableIdentifier) {
+ return delegate==null?null:delegate.tableToMetaAttributes( tableIdentifier );
+ }
+
+ public Map columnToMetaAttributes(TableIdentifier identifier, String column) {
+ return delegate==null?null:delegate.columnToMetaAttributes( identifier, column );
+ }
}
Added: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/MetaAttributeBinder.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/MetaAttributeBinder.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/MetaAttributeBinder.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -0,0 +1,122 @@
+package org.hibernate.cfg.reveng;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.collections.MultiHashMap;
+import org.apache.commons.collections.MultiMap;
+import org.dom4j.Element;
+import org.hibernate.mapping.MetaAttribute;
+import org.hibernate.tool.hbm2x.MetaAttributeHelper;
+
+public class MetaAttributeBinder {
+
+ static class SimpleMetaAttribute {
+ String value;
+ boolean inheritable = true;
+
+ public SimpleMetaAttribute(String value, boolean inherit) {
+ this.value = value;
+ this.inheritable = inherit;
+ }
+
+ public String toString() {
+ return value;
+ }
+ }
+
+ /**
+ * Merges a Multimap with inherited maps.
+ * Values specified always overrules/replaces the inherited values.
+ *
+ * @param specific
+ * @param general
+ * @return a MultiMap with all values from local and extra values
+ * from inherited
+ */
+ public static MultiMap mergeMetaMaps(Map specific, Map general) {
+ MultiHashMap result = new MultiHashMap();
+ MetaAttributeHelper.copyMultiMap(result, specific);
+
+ if (general != null) {
+ for (Iterator iter = general.keySet().iterator();
+ iter.hasNext();
+ ) {
+ String key = (String) iter.next();
+
+ if (!specific.containsKey(key) ) {
+ // inheriting a meta attribute only if it is inheritable
+ Collection ml = (Collection) general.get(key);
+ for (Iterator iterator = ml.iterator();
+ iterator.hasNext();
+ ) {
+ MetaAttributeBinder.SimpleMetaAttribute element = (MetaAttributeBinder.SimpleMetaAttribute) iterator.next();
+ if (element.inheritable) {
+ result.put(key, element);
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+
+ }
+
+ public static MetaAttribute toRealMetaAttribute(String name, List values) {
+ MetaAttribute attribute = new MetaAttribute(name);
+ for (Iterator iter = values.iterator(); iter.hasNext();) {
+ MetaAttributeBinder.SimpleMetaAttribute element = (MetaAttributeBinder.SimpleMetaAttribute) iter.next();
+ attribute.addValue(element.value);
+ }
+
+ return attribute;
+ }
+
+
+ /**
+ * Method loadAndMergeMetaMap.
+ * @param classElement
+ * @param inheritedMeta
+ * @return MultiMap
+ */
+ public static MultiMap loadAndMergeMetaMap(
+ Element classElement,
+ MultiMap inheritedMeta) {
+ return MetaAttributeBinder.mergeMetaMaps(loadMetaMap(classElement), inheritedMeta);
+ }
+
+
+ /**
+ * Load meta attributes from jdom element into a MultiMap.
+ *
+ * @param element
+ * @return MultiMap
+ */
+ protected static MultiMap loadMetaMap(Element element) {
+ MultiMap result = new MultiHashMap();
+ List metaAttributeList = new ArrayList();
+ metaAttributeList.addAll(element.elements("meta") );
+
+ for (Iterator iter = metaAttributeList.iterator(); iter.hasNext();) {
+ Element metaAttrib = (Element) iter.next();
+ // does not use getTextNormalize() or getTextTrim() as that would remove the formatting in new lines in items like description for javadocs.
+ String attribute = metaAttrib.attributeValue("attribute");
+ String value = metaAttrib.getText();
+ String inheritStr= metaAttrib.attributeValue("inherit");
+ boolean inherit = true;
+ if(inheritStr!=null) {
+ inherit = Boolean.valueOf(inheritStr).booleanValue();
+ }
+
+ MetaAttributeBinder.SimpleMetaAttribute ma = new MetaAttributeBinder.SimpleMetaAttribute(value, inherit);
+ result.put(attribute, ma);
+ }
+ return result;
+
+ }
+
+}
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideBinder.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideBinder.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideBinder.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -1,16 +1,20 @@
package org.hibernate.cfg.reveng;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
+import org.apache.commons.collections.MultiHashMap;
+import org.apache.commons.collections.MultiMap;
import org.dom4j.Document;
import org.dom4j.Element;
import org.hibernate.MappingException;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.ForeignKey;
import org.hibernate.mapping.Table;
+import org.hibernate.tool.hbm2x.MetaAttributeHelper;
import org.hibernate.util.StringHelper;
@@ -81,6 +85,7 @@
List foreignKeys = element.elements("foreign-key");
bindForeignKeys(foreignKeys, table, repository);
+ bindMetaAttributes(element, table, repository);
repository.addTable(table,wantedClassName);
@@ -88,6 +93,13 @@
}
+ private static void bindMetaAttributes(Element element, Table table, OverrideRepository repository) {
+ MultiMap map = MetaAttributeBinder.loadAndMergeMetaMap( element, new MultiHashMap());
+ if(map!=null && !map.isEmpty()) {
+ repository.addMetaAttributeInfo( table, map);
+ }
+ }
+
private static void bindPrimaryKey(Element identifier, Table table, OverrideRepository repository) {
if(identifier==null) return;
@@ -203,6 +215,11 @@
throw new MappingException("Column " + column.getName() + " already exists in table " + tableIdentifier );
}
+ MultiMap map = MetaAttributeBinder.loadAndMergeMetaMap( element, new MultiHashMap());
+ if(map!=null && !map.isEmpty()) {
+ repository.addMetaAttributeInfo( tableIdentifier, column.getName(), map);
+ }
+
table.addColumn(column);
columnNames.add(column.getName());
repository.setTypeNameForColumn(tableIdentifier, column.getName(), element.attributeValue("type"));
@@ -238,6 +255,8 @@
key.setReferencedTable(foreignTable); // only possible if foreignColumns is explicitly specified (workaround on aligncolumns)
}
+
+
}
return columnNames;
@@ -258,6 +277,13 @@
filter.setMatchName(element.attributeValue("match-name") );
filter.setExclude(Boolean.valueOf(element.attributeValue("exclude") ) );
filter.setPackage(element.attributeValue("package") );
+
+ MultiMap map = MetaAttributeBinder.loadAndMergeMetaMap( element, new MultiHashMap());
+ if(map!=null && !map.isEmpty()) {
+ filter.setMetaAttributes( map );
+ } else {
+ filter.setMetaAttributes( null );
+ }
respository.addTableFilter(filter);
}
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -5,6 +5,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.Iterator;
@@ -15,12 +16,14 @@
import net.sf.cglib.core.KeyFactory;
+import org.apache.commons.collections.MultiMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
import org.hibernate.MappingException;
import org.hibernate.mapping.ForeignKey;
import org.hibernate.mapping.Table;
+import org.hibernate.tool.hbm2x.MetaAttributeHelper;
import org.hibernate.util.StringHelper;
import org.hibernate.util.XMLHelper;
import org.xml.sax.EntityResolver;
@@ -67,6 +70,10 @@
final private Map foreignKeyCollectionExclude;
final private Map foreignKeyManyToOneExclude;
+
+ final private Map tableMetaAttributes; // TI -> MultiMap of SimpleMetaAttributes
+
+ final private Map columnMetaAttributes;
//private String defaultCatalog;
//private String defaultSchema;
@@ -94,6 +101,8 @@
foreignKeyToCollectionName = new HashMap();
foreignKeyCollectionExclude = new HashMap();
foreignKeyManyToOneExclude = new HashMap();
+ tableMetaAttributes = new HashMap();
+ columnMetaAttributes = new HashMap();
}
public OverrideRepository addFile(File xmlFile) {
@@ -264,10 +273,19 @@
public ReverseEngineeringStrategy getReverseEngineeringStrategy(ReverseEngineeringStrategy delegate) {
return new DelegatingReverseEngineeringStrategy(delegate) {
+
public boolean excludeTable(TableIdentifier ti) {
return OverrideRepository.this.excludeTable(ti);
}
+ public Map tableToMetaAttributes(TableIdentifier tableIdentifier) {
+ return OverrideRepository.this.tableToMetaAttributes(tableIdentifier);
+ }
+
+ public Map columnToMetaAttributes(TableIdentifier tableIdentifier, String column) {
+ return OverrideRepository.this.columnToMetaAttributes(tableIdentifier, column);
+ }
+
public boolean excludeColumn(TableIdentifier identifier, String columnName) {
return excludedColumns.contains(TABLECOLUMN_KEY_FACTORY.newInstance(identifier, columnName));
}
@@ -435,6 +453,70 @@
};
}
+ protected Map columnToMetaAttributes(TableIdentifier tableIdentifier, String column) {
+ Map specific = (Map) columnMetaAttributes.get( TABLECOLUMN_KEY_FACTORY.newInstance(tableIdentifier, column) );
+ if(specific!=null && !specific.isEmpty()) {
+ return toMetaAttributes(specific);
+ }
+
+ return null;
+ }
+
+ // TODO: optimize
+ protected Map tableToMetaAttributes(TableIdentifier identifier) {
+ Map specific = (Map) tableMetaAttributes.get( identifier );
+ if(specific!=null && !specific.isEmpty()) {
+ return toMetaAttributes(specific);
+ }
+ Map general = findGeneralAttributes( identifier );
+ if(general!=null && !general.isEmpty()) {
+ return toMetaAttributes(general);
+ }
+
+ return null;
+
+ /* inheritance not defined yet
+ if(specific==null) { specific = Collections.EMPTY_MAP; }
+ if(general==null) { general = Collections.EMPTY_MAP; }
+
+ MultiMap map = MetaAttributeBinder.mergeMetaMaps( specific, general );
+ */
+ /*
+ if(map!=null && !map.isEmpty()) {
+ return toMetaAttributes(null, map);
+ } else {
+ return null;
+ }
+ */
+ }
+
+ private Map findGeneralAttributes(TableIdentifier identifier) {
+ Iterator iterator = tableFilters.iterator();
+ while(iterator.hasNext() ) {
+ TableFilter tf = (TableFilter) iterator.next();
+ Map value = tf.getMetaAttributes(identifier);
+ if(value!=null) {
+ return value;
+ }
+ }
+ return null;
+ }
+
+ private Map toMetaAttributes(Map value) {
+ Map result = new HashMap();
+
+ Set set = value.entrySet();
+ for (Iterator iter = set.iterator(); iter.hasNext();) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ String name = (String) entry.getKey();
+ List values = (List) entry.getValue();
+
+ result.put(name, MetaAttributeBinder.toRealMetaAttribute(name, values));
+ }
+
+ return result;
+ }
+
public ReverseEngineeringStrategy getReverseEngineeringStrategy() {
return getReverseEngineeringStrategy(null);
}
@@ -533,6 +615,21 @@
}
}
+ public void addMetaAttributeInfo(Table table, Map map) {
+ if(map!=null && !map.isEmpty()) {
+ tableMetaAttributes.put(TableIdentifier.create(table), map);
+ }
+
+ }
+
+ public void addMetaAttributeInfo(TableIdentifier tableIdentifier, String name, MultiMap map) {
+ if(map!=null && !map.isEmpty()) {
+ columnMetaAttributes.put(TABLECOLUMN_KEY_FACTORY.newInstance( tableIdentifier, name ), map);
+ }
+
+ }
+
+
}
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -1,11 +1,13 @@
package org.hibernate.cfg.reveng;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.mapping.ForeignKey;
+import org.hibernate.mapping.MetaAttribute;
import org.hibernate.mapping.Table;
public interface ReverseEngineeringStrategy {
@@ -96,17 +98,42 @@
public boolean useColumnForOptimisticLock(TableIdentifier identifier, String column);
- /** return list of SchemaSelctors
+ /**
+ * Return list of SchemaSelctors to be used when asking {@link MetaDataDialect} for metadata.
*
- * @return null
+ * @return list of {@link SchemaSelection} instances
*/
public List getSchemaSelections();
+ /**
+ * Given a table name, return the wanted name for the identifier.
+ * @param tableIdentifier
+ * @return name to be used for identification
+ */
public String tableToIdentifierPropertyName(TableIdentifier tableIdentifier);
+ /**
+ * Given a table name, return the wanted name for a composite identifier.
+ * @param identifier
+ * @return
+ */
public String tableToCompositeIdName(TableIdentifier identifier);
+ /**
+ * Return the list of metaattributes to assign to classes created based on the given table
+ * @param tableIdentifier
+ * @return a Map from String to {@link MetaAttribute}
+ */
+ public Map tableToMetaAttributes(TableIdentifier tableIdentifier);
+ /**
+ * Return the list of metaattributes to assign to properties created based on the given column
+ * @param tableIdentifier
+ * @param column
+ * @return a Map from String to {@link MetaAttribute}
+ */
+ public Map columnToMetaAttributes(TableIdentifier identifier, String column);
+
/** Should this foreignkey be excluded as a oneToMany */
public boolean excludeForeignKeyAsCollection(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns);
@@ -152,5 +179,8 @@
* @return
*/
public String foreignKeyToManyToManyName(ForeignKey fromKey, TableIdentifier middleTable, ForeignKey toKey, boolean uniqueReference);
+
+
+
}
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableFilter.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableFilter.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableFilter.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -1,6 +1,8 @@
package org.hibernate.cfg.reveng;
+import java.util.Map;
+
/**
*
* A tablefilter that can tell if a TableIdentifier is included or excluded.
@@ -71,6 +73,7 @@
private Matcher catalogMatcher;
private Matcher schemaMatcher;
private Matcher nameMatcher;
+ private Map metaAttributes;
@@ -100,7 +103,7 @@
public Boolean exclude(TableIdentifier identifier) {
return isRelevantFor(identifier) ? exclude : null;
}
-
+
public void setExclude(Boolean bool) {
exclude = bool;
}
@@ -143,4 +146,12 @@
public Boolean getExclude() {
return exclude;
}
+
+ public Map getMetaAttributes(TableIdentifier identifier) {
+ return isRelevantFor(identifier) ? metaAttributes : null;
+ }
+
+ public void setMetaAttributes(Map metaAttributes) {
+ this.metaAttributes = metaAttributes;
+ }
}
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/hibernate-reverse-engineering-3.0.dtd
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/hibernate-reverse-engineering-3.0.dtd 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/hibernate-reverse-engineering-3.0.dtd 2006-09-25 16:14:29 UTC (rev 10529)
@@ -44,7 +44,7 @@
<!-- Table pattern for the selection -->
<!ATTLIST schema-selection match-table CDATA #IMPLIED >
-<!ELEMENT table (primary-key?, column*, foreign-key*) >
+<!ELEMENT table (meta*, primary-key?, column*, foreign-key*) >
<!-- Catalog for the table -->
<!ATTLIST table catalog CDATA #IMPLIED >
<!-- Schema for the table -->
@@ -54,7 +54,7 @@
<!-- The class name to use for the table -->
<!ATTLIST table class CDATA #IMPLIED >
-<!ELEMENT column EMPTY >
+<!ELEMENT column (meta*) >
<!ATTLIST column name CDATA #REQUIRED >
<!ATTLIST column jdbc-type CDATA #IMPLIED >
<!ATTLIST column type CDATA #IMPLIED >
@@ -107,10 +107,18 @@
<!ATTLIST bag property CDATA #REQUIRED> -->
<!-- a table-filter allows to explicitly exclude or include tables or complete catalog/schemas into the reverse engineering -->
-<!ELEMENT table-filter EMPTY >
+<!ELEMENT table-filter (meta)* >
<!ATTLIST table-filter match-catalog CDATA ".*" >
<!ATTLIST table-filter match-schema CDATA ".*" >
<!ATTLIST table-filter match-name CDATA #REQUIRED >
<!ATTLIST table-filter exclude (true|false) "false" >
<!ATTLIST table-filter package CDATA #IMPLIED >
+<!--
+ META element definition; used to assign meta-level attributes.
+-->
+<!ELEMENT meta (#PCDATA)>
+ <!ATTLIST meta attribute CDATA #REQUIRED>
+
+
+
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/MetaAttributeHelper.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/MetaAttributeHelper.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/MetaAttributeHelper.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -4,10 +4,13 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.apache.commons.collections.MultiHashMap;
import org.apache.commons.collections.MultiMap;
import org.dom4j.Element;
+import org.hibernate.cfg.reveng.MetaAttributeBinder;
+import org.hibernate.mapping.MetaAttribute;
/**
* Helper for loading, merging and accessing <meta> tags.
@@ -22,99 +25,7 @@
//noop
}
- static class SimpleMetaAttribute {
- String value;
- boolean inheritable = true;
-
- SimpleMetaAttribute(String value, boolean inherit) {
- this.value = value;
- this.inheritable = inherit;
- }
-
- public String toString() {
- return value;
- }
- }
-
/**
- * Load meta attributes from jdom element into a MultiMap.
- *
- * @param element
- * @return MultiMap
- */
- protected static MultiMap loadMetaMap(Element element) {
- MultiMap result = new MultiHashMap();
- List metaAttributeList = new ArrayList();
- metaAttributeList.addAll(element.elements("meta") );
-
- for (Iterator iter = metaAttributeList.iterator(); iter.hasNext();) {
- Element metaAttrib = (Element) iter.next();
- // does not use getTextNormalize() or getTextTrim() as that would remove the formatting in new lines in items like description for javadocs.
- String attribute = metaAttrib.attributeValue("attribute");
- String value = metaAttrib.getText();
- String inheritStr= metaAttrib.attributeValue("inherit");
- boolean inherit = true;
- if(inheritStr!=null) {
- inherit = Boolean.valueOf(inheritStr).booleanValue();
- }
-
- SimpleMetaAttribute ma = new SimpleMetaAttribute(value, inherit);
- result.put(attribute, ma);
- }
- return result;
-
- }
-
- /**
- * Merges a Multimap with inherited maps.
- * Values specified always overrules/replaces the inherited values.
- *
- * @param local
- * @param inherited
- * @return a MultiMap with all values from local and extra values
- * from inherited
- */
- public static MultiMap mergeMetaMaps(MultiMap local, MultiMap inherited) {
- MultiHashMap result = new MultiHashMap();
- copyMultiMap(result, local);
-
- if (inherited != null) {
- for (Iterator iter = inherited.keySet().iterator();
- iter.hasNext();
- ) {
- String key = (String) iter.next();
-
- if (!local.containsKey(key) ) {
- // inheriting a meta attribute only if it is inheritable
- Collection ml = (Collection) inherited.get(key);
- for (Iterator iterator = ml.iterator();
- iterator.hasNext();
- ) {
- SimpleMetaAttribute element = (SimpleMetaAttribute) iterator.next();
- if (element.inheritable) {
- result.put(key, element);
- }
- }
- }
- }
- }
-
- return result;
-
- }
- /**
- * Method loadAndMergeMetaMap.
- * @param classElement
- * @param inheritedMeta
- * @return MultiMap
- */
- public static MultiMap loadAndMergeMetaMap(
- Element classElement,
- MultiMap inheritedMeta) {
- return mergeMetaMaps(loadMetaMap(classElement), inheritedMeta);
- }
-
- /**
* @param collection
* @param string
*/
@@ -166,12 +77,12 @@
* of the MultiMap, and should work with all versions.
*
* @param destination
- * @param source
+ * @param specific
*/
- public static void copyMultiMap(MultiMap destination, MultiMap source) {
- for (Iterator keyIterator = source.keySet().iterator(); keyIterator.hasNext(); ) {
+ public static void copyMultiMap(MultiMap destination, Map specific) {
+ for (Iterator keyIterator = specific.keySet().iterator(); keyIterator.hasNext(); ) {
Object key = keyIterator.next();
- Collection c = (Collection) source.get(key);
+ Collection c = (Collection) specific.get(key);
for (Iterator valueIterator = c.iterator(); valueIterator.hasNext(); )
destination.put(key, valueIterator.next() );
}
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -592,6 +592,7 @@
annotation.append("\n @");
annotation.append( importType( "javax.persistence.JoinTable") ).append( "(name=\"" );
Table table = collection.getCollectionTable();
+
annotation.append( table.getName() );
annotation.append( "\"" );
if ( StringHelper.isNotEmpty( table.getSchema() ) ) {
Modified: trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -26,6 +26,7 @@
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.ForeignKey;
+import org.hibernate.mapping.MetaAttribute;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.SimpleValue;
@@ -169,6 +170,15 @@
assertEquals("orderName", repository.columnToPropertyName(new TableIdentifier(null, null, "ORDERS"), "NAME"));
}
+ public void testMetaAttributeMappings() {
+ PersistentClass classMapping = cfg.getClassMapping( "Orders" );
+ assertEquals("order table value", classMapping.getMetaAttribute( "order-meta" ).getValue());
+
+ Property property = classMapping.getProperty("orderName");
+ assertEquals("order column value", property.getMetaAttribute( "order-meta" ).getValue());
+ //TODO: test sequence of meta
+ }
+
public void testIdGenerator() {
OverrideRepository or = buildOverrideRepository();
@@ -422,6 +432,51 @@
}
+ public void testMetaAttributes() {
+
+ ReverseEngineeringStrategy res = buildOverrideRepository().addResource(OVERRIDETEST_REVENG_XML).getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy());
+
+ TableIdentifier tableIdentifier = new TableIdentifier(null, null, "TblTest");
+ Map attributes = res.tableToMetaAttributes(tableIdentifier);
+ assertNotNull(attributes);
+ assertEquals(attributes.size(),1);
+ MetaAttribute ma = (MetaAttribute) attributes.get("use-in-test");
+ assertEquals(ma.getName(), "use-in-test");
+ assertEquals(ma.getValue(), "true");
+
+ tableIdentifier = new TableIdentifier(settings.getDefaultCatalogName(), "Werd", "Testy");
+ attributes = res.tableToMetaAttributes( tableIdentifier );
+ assertNotNull(attributes);
+ ma = (MetaAttribute) attributes.get( "werd-meta" );
+ assertEquals(ma.getName(), "werd-meta");
+ assertEquals(ma.getValues().size(), 2);
+
+ tableIdentifier = new TableIdentifier(null, "Werd", "MetaTable");
+ attributes = res.tableToMetaAttributes( tableIdentifier );
+ assertNotNull(attributes);
+ assertEquals(2, attributes.size());
+ ma = (MetaAttribute) attributes.get("specific-werd");
+ assertEquals(ma.getName(), "specific-werd");
+ assertEquals(ma.getValue(), "a one");
+
+ ma = (MetaAttribute) attributes.get( "werd-meta" );
+ assertEquals(ma.getName(), "werd-meta");
+ assertEquals(1, ma.getValues().size()); // as long as no inherit this should be one
+ assertEquals("value three", ma.getValue());
+
+ tableIdentifier = new TableIdentifier(null, null, "Nothing");
+ assertEquals(null, res.tableToMetaAttributes(tableIdentifier));
+
+ assertNull(res.columnToMetaAttributes(new TableIdentifier("Nothing"), "bogus"));
+ assertNull(res.columnToMetaAttributes( new TableIdentifier(null, "Werd", "MetaTable"), "bogusColumn" ));
+ attributes = res.columnToMetaAttributes( new TableIdentifier(null, "Werd", "MetaTable"), "MetaColumn" );
+ assertEquals(1, attributes.size());
+ ma = (MetaAttribute) attributes.get("specific-column");
+ assertEquals("specific-column",ma.getName());
+ assertEquals("yes a column with meta",ma.getValue());
+
+ }
+
protected void configure(JDBCMetaDataConfiguration cfg) {
super.configure(cfg);
Settings s = cfg.buildSettings();
Modified: trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/overridetest.reveng.xml
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/overridetest.reveng.xml 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/overridetest.reveng.xml 2006-09-25 16:14:29 UTC (rev 10529)
@@ -13,8 +13,11 @@
hibernate-type="string" />
</type-mapping>
- <table-filter match-schema="Werd" match-name=".*"
- package="org.werd" />
+ <table-filter match-schema="Werd" match-name=".*" package="org.werd">
+ <meta attribute="werd-meta">value one</meta>
+ <meta attribute="werd-meta">value two</meta>
+ </table-filter>
+
<table-filter match-name="DEFUNCT_TABLE" exclude="true" />
<table-filter match-name="DoNotWantIt" exclude="true" />
<table-filter match-name="WantedTable" />
@@ -45,12 +48,15 @@
alter table Customer add constraint 'max' foreign key (addressid, x) references address (dfdf)
-->
<table name="ORDERS">
+ <meta attribute="order-meta">order table value</meta>
<primary-key property="customOrderId" id-class="CustomOID">
<!-- <column name="CUSTID" foreign-table="CUSTOMER" foreign-column="CUSTID" /> -->
<key-column name="ORDERID"/>
<key-column name="CUSTID"/>
</primary-key>
- <column name="NAME" property="orderName" type="string" />
+ <column name="NAME" property="orderName" type="string">
+ <meta attribute="order-meta">order column value</meta>
+ </column>
<foreign-key foreign-table="CUSTOMER">
<column-ref local-column="CUSTID" foreign-column="CUSTID"/>
@@ -79,8 +85,18 @@
<column name="EXCOLUMN" exclude="true"/>
</table>
- <table name="TblTest" class="org.test.Test"/>
+ <table name="TblTest" class="org.test.Test">
+ <meta attribute="use-in-test">true</meta>
+ </table>
+ <table schema="Werd" name="MetaTable">
+ <meta attribute="specific-werd">a one</meta>
+ <meta attribute="werd-meta">value three</meta>
+ <column name="MetaColumn">
+ <meta attribute="specific-column">yes a column with meta</meta>
+ </column>
+ </table>
+
<table schema="Werd" name="TBL_PKG" class="MyWorld"/>
<table schema="Werd" name="TBL_OTHER" class="other.MyWorld"/>
Modified: trunk/HibernateExt/tools/src/testsupport/NoopReverseEngineeringStrategy.java
===================================================================
--- trunk/HibernateExt/tools/src/testsupport/NoopReverseEngineeringStrategy.java 2006-09-25 15:14:10 UTC (rev 10528)
+++ trunk/HibernateExt/tools/src/testsupport/NoopReverseEngineeringStrategy.java 2006-09-25 16:14:29 UTC (rev 10529)
@@ -1,4 +1,5 @@
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.hibernate.cfg.reveng.ReverseEngineeringSettings;
@@ -152,4 +153,14 @@
// TODO Auto-generated method stub
return null;
}
+
+ public Map tableToMetaAttributes(TableIdentifier tableIdentifier) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Map columnToMetaAttributes(TableIdentifier identifier, String column) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
18 years, 2 months
Hibernate SVN: r10528 - branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-25 11:14:10 -0400 (Mon, 25 Sep 2006)
New Revision: 10528
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/SelectClause.java
Log:
HHH-2103 rollback mandatory select in JPA
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/SelectClause.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/SelectClause.java 2006-09-25 15:13:41 UTC (rev 10527)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/SelectClause.java 2006-09-25 15:14:10 UTC (rev 10528)
@@ -256,10 +256,12 @@
if ( prepared ) {
throw new IllegalStateException( "SelectClause was already prepared!" );
}
- if ( getSessionFactoryHelper().isStrictJPAQLComplianceEnabled() && !getWalker().isSubQuery() ) {
- // NOTE : the isSubQuery() bit is a temporary hack...
- throw new QuerySyntaxException( "JPA-QL compliance requires select clause" );
- }
+
+ //Used to be tested by the TCK but the test is no longer here
+// if ( getSessionFactoryHelper().isStrictJPAQLComplianceEnabled() && !getWalker().isSubQuery() ) {
+// // NOTE : the isSubQuery() bit is a temporary hack...
+// throw new QuerySyntaxException( "JPA-QL compliance requires select clause" );
+// }
List fromElements = fromClause.getProjectionList();
ASTAppender appender = new ASTAppender( getASTFactory(), this ); // Get ready to start adding nodes.
18 years, 2 months
Hibernate SVN: r10527 - trunk/Hibernate3/src/org/hibernate/hql/ast/tree
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-25 11:13:41 -0400 (Mon, 25 Sep 2006)
New Revision: 10527
Modified:
trunk/Hibernate3/src/org/hibernate/hql/ast/tree/SelectClause.java
Log:
HHH-2103 rollback mandatory select in JPA
Modified: trunk/Hibernate3/src/org/hibernate/hql/ast/tree/SelectClause.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/hql/ast/tree/SelectClause.java 2006-09-22 19:20:51 UTC (rev 10526)
+++ trunk/Hibernate3/src/org/hibernate/hql/ast/tree/SelectClause.java 2006-09-25 15:13:41 UTC (rev 10527)
@@ -256,10 +256,11 @@
if ( prepared ) {
throw new IllegalStateException( "SelectClause was already prepared!" );
}
- if ( getSessionFactoryHelper().isStrictJPAQLComplianceEnabled() && !getWalker().isSubQuery() ) {
- // NOTE : the isSubQuery() bit is a temporary hack...
- throw new QuerySyntaxException( "JPA-QL compliance requires select clause" );
- }
+ //Used to be tested by the TCK but the test is no longer here
+// if ( getSessionFactoryHelper().isStrictJPAQLComplianceEnabled() && !getWalker().isSubQuery() ) {
+// // NOTE : the isSubQuery() bit is a temporary hack...
+// throw new QuerySyntaxException( "JPA-QL compliance requires select clause" );
+// }
List fromElements = fromClause.getProjectionList();
ASTAppender appender = new ASTAppender( getASTFactory(), this ); // Get ready to start adding nodes.
18 years, 2 months
Hibernate SVN: r10526 - in trunk/HibernateExt: ejb/lib ejb/src/test/org/hibernate/ejb/test/cascade metadata/lib
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-22 15:20:51 -0400 (Fri, 22 Sep 2006)
New Revision: 10526
Added:
trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Author.java
trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Song.java
Modified:
trunk/HibernateExt/ejb/lib/ejb3-persistence.jar
trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/CascadeTest.java
trunk/HibernateExt/metadata/lib/ejb3-persistence.jar
Log:
New Sig EJB3
Modified: trunk/HibernateExt/ejb/lib/ejb3-persistence.jar
===================================================================
(Binary files differ)
Added: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Author.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Author.java 2006-09-22 19:14:47 UTC (rev 10525)
+++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Author.java 2006-09-22 19:20:51 UTC (rev 10526)
@@ -0,0 +1,19 @@
+//$Id: $
+package org.hibernate.ejb.test.cascade;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.GenerationType;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Author {
+ @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ENTITY2_SEQ")
+ @SequenceGenerator(name = "ENTITY2_SEQ")
+ private Long id;
+
+}
Modified: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/CascadeTest.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/CascadeTest.java 2006-09-22 19:14:47 UTC (rev 10525)
+++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/CascadeTest.java 2006-09-22 19:20:51 UTC (rev 10526)
@@ -1,9 +1,8 @@
//$Id: FetchTest.java 9796 2006-04-26 06:46:52Z epbernard $
package org.hibernate.ejb.test.cascade;
-import java.util.List;
-
import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
import org.hibernate.ejb.test.TestCase;
@@ -54,11 +53,42 @@
}
+ public void testNoCascadeAndMerge() throws Exception {
+ Song e1 = new Song();
+ Author e2 = new Author();
+ e1.setAuthor(e2);
+
+ EntityManager em = factory.createEntityManager();
+ EntityTransaction tx = em.getTransaction();
+ tx.begin();
+ em.persist(e2);
+ em.persist(e1);
+ tx.commit();
+ em.close();
+
+ em = factory.createEntityManager();
+
+ e1 = em.find(Song.class, e1.getId());
+ e2 = null;
+
+
+ tx = em.getTransaction();
+ tx.begin();
+ em.merge(e1);
+ //em.refresh(e1);
+ tx.commit();
+ em.close();
+
+ }
+
+
public Class[] getAnnotatedClasses() {
return new Class[]{
Teacher.class,
- Student.class
+ Student.class,
+ Song.class,
+ Author.class
};
}
Added: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Song.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Song.java 2006-09-22 19:14:47 UTC (rev 10525)
+++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Song.java 2006-09-22 19:20:51 UTC (rev 10526)
@@ -0,0 +1,38 @@
+//$Id: $
+package org.hibernate.ejb.test.cascade;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.FetchType;
+import javax.persistence.ManyToOne;
+import javax.persistence.GenerationType;
+import javax.persistence.SequenceGenerator;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Song {
+ @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ENTITY1_SEQ")
+ @SequenceGenerator(name = "ENTITY1_SEQ") private Long id;
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
+ private Author author;
+
+ public Author getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(Author author) {
+ this.author = author;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+}
Modified: trunk/HibernateExt/metadata/lib/ejb3-persistence.jar
===================================================================
(Binary files differ)
18 years, 2 months
Hibernate SVN: r10525 - in trunk/HibernateExt/ejb-api/src/javax/persistence: . spi
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-22 15:14:47 -0400 (Fri, 22 Sep 2006)
New Revision: 10525
Added:
trunk/HibernateExt/ejb-api/src/javax/persistence/package-info.java
trunk/HibernateExt/ejb-api/src/javax/persistence/spi/package-info.java
Modified:
trunk/HibernateExt/ejb-api/src/javax/persistence/JoinColumn.java
trunk/HibernateExt/ejb-api/src/javax/persistence/JoinColumns.java
trunk/HibernateExt/ejb-api/src/javax/persistence/UniqueConstraint.java
Log:
TYPE target removed in SigTest
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/JoinColumn.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/JoinColumn.java 2006-09-22 16:29:49 UTC (rev 10524)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/JoinColumn.java 2006-09-22 19:14:47 UTC (rev 10525)
@@ -13,7 +13,7 @@
*
* @author Emmanuel Bernard
*/
-@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface JoinColumn {
/**
* The name of the foreign key column.
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/JoinColumns.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/JoinColumns.java 2006-09-22 16:29:49 UTC (rev 10524)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/JoinColumns.java 2006-09-22 19:14:47 UTC (rev 10525)
@@ -17,7 +17,7 @@
* @author Emmanuel Bernard
*/
-@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface JoinColumns {
JoinColumn[] value();
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/UniqueConstraint.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/UniqueConstraint.java 2006-09-22 16:29:49 UTC (rev 10524)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/UniqueConstraint.java 2006-09-22 19:14:47 UTC (rev 10525)
@@ -2,7 +2,6 @@
//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
package javax.persistence;
-import static java.lang.annotation.ElementType.TYPE;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
@@ -13,7 +12,7 @@
*
* @author Emmanuel Bernard
*/
-@Target({TYPE}) @Retention(RUNTIME)
+@Target({}) @Retention(RUNTIME)
public @interface UniqueConstraint {
/**
* An array of the column names that make up the constraint
Added: trunk/HibernateExt/ejb-api/src/javax/persistence/package-info.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/package-info.java 2006-09-22 16:29:49 UTC (rev 10524)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/package-info.java 2006-09-22 19:14:47 UTC (rev 10525)
@@ -0,0 +1,9 @@
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+
+/**
+ * The javax.persistence package contains the classes and interfaces that define the contracts
+ * between a persistence provider and the managed classes and the clients of the Java Persistence API.
+ */
+package javax.persistence;
+
Added: trunk/HibernateExt/ejb-api/src/javax/persistence/spi/package-info.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/spi/package-info.java 2006-09-22 16:29:49 UTC (rev 10524)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/spi/package-info.java 2006-09-22 19:14:47 UTC (rev 10525)
@@ -0,0 +1,10 @@
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+
+/**
+ * The javax.persistence.spi package defines the classes and interfaces that are implemented by the
+ * persistence provider and the Java EE container for use by the container, provider, and/or Persistence
+ * bootstrap class in deployment and bootstrapping.
+ */
+package javax.persistence.spi;
+
18 years, 2 months
Hibernate SVN: r10524 - trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-22 12:29:49 -0400 (Fri, 22 Sep 2006)
New Revision: 10524
Added:
trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Mail.java
Modified:
trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/GetReferenceTest.java
Log:
more tests
Modified: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/GetReferenceTest.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/GetReferenceTest.java 2006-09-22 12:55:59 UTC (rev 10523)
+++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/GetReferenceTest.java 2006-09-22 16:29:49 UTC (rev 10524)
@@ -23,13 +23,25 @@
catch ( Exception e ) {
fail("Wrong exception: " + e );
}
+
+ try {
+ Mail c = em.getReference( Mail.class, 1 );
+ fail("Expected IllegalArgumentException");
+ }
+ catch (IllegalArgumentException e) {
+ //success
+ }
+ catch ( Exception e ) {
+ fail("Wrong exception: " + e );
+ }
em.close();
}
public Class[] getAnnotatedClasses() {
return new Class[] {
Competitor.class,
- Race.class
+ Race.class,
+ Mail.class
};
}
}
Added: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Mail.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Mail.java 2006-09-22 12:55:59 UTC (rev 10523)
+++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Mail.java 2006-09-22 16:29:49 UTC (rev 10524)
@@ -0,0 +1,31 @@
+//$Id: $
+package org.hibernate.ejb.test.emops;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Mail {
+ @Id private Long id;
+ private String from;
+
+ public String getFrom() {
+ return from;
+ }
+
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+}
18 years, 2 months
Hibernate SVN: r10523 - tags/TOOLS_3_2_0_BETA8
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-09-22 08:55:59 -0400 (Fri, 22 Sep 2006)
New Revision: 10523
Added:
tags/TOOLS_3_2_0_BETA8/tools/
Log:
b8
Copied: tags/TOOLS_3_2_0_BETA8/tools (from rev 10522, trunk/HibernateExt/tools)
18 years, 2 months
Hibernate SVN: r10522 - in trunk/HibernateExt/tools/src/test/org/hibernate/tool: . stat
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-09-22 08:51:20 -0400 (Fri, 22 Sep 2006)
New Revision: 10522
Modified:
trunk/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java
trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java
Log:
Modified: trunk/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java 2006-09-22 12:28:16 UTC (rev 10521)
+++ trunk/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java 2006-09-22 12:51:20 UTC (rev 10522)
@@ -2,7 +2,6 @@
package org.hibernate.tool;
import java.io.File;
-import java.util.Iterator;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
@@ -11,9 +10,6 @@
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.mapping.ForeignKey;
-import org.hibernate.mapping.Index;
-import org.hibernate.mapping.Table;
import org.hibernate.tool.test.TestHelper;
public abstract class NonReflectiveTestCase extends BaseTestCase {
Modified: trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java 2006-09-22 12:28:16 UTC (rev 10521)
+++ trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java 2006-09-22 12:51:20 UTC (rev 10522)
@@ -1,21 +1,19 @@
package org.hibernate.tool.stat;
import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
import org.hibernate.classic.Session;
-import org.hibernate.test.TestCase;
+import org.hibernate.tool.NonReflectiveTestCase;
-public class StatisticsBrowserTest extends TestCase {
+public class StatisticsBrowserTest extends NonReflectiveTestCase {
public StatisticsBrowserTest(String name) {
super( name );
}
-
+ /*
protected void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.USE_STRUCTURED_CACHE, "true" );
- }
+ }*/
public void testBrowser() throws Exception {
getSessions().getStatistics().setStatisticsEnabled( true );
18 years, 2 months
Hibernate SVN: r10521 - tags
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-09-22 08:28:16 -0400 (Fri, 22 Sep 2006)
New Revision: 10521
Added:
tags/TOOLS_3_2_0_BETA8/
Log:
18 years, 2 months
Hibernate SVN: r10520 - trunk/Hibernate3/src/org/hibernate/event/def
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-09-21 21:51:36 -0400 (Thu, 21 Sep 2006)
New Revision: 10520
Modified:
trunk/Hibernate3/src/org/hibernate/event/def/AbstractFlushingEventListener.java
Log:
HHH-2093 PERSIST_ON_FLUSH ineffective for recursive object graphs
Modified: trunk/Hibernate3/src/org/hibernate/event/def/AbstractFlushingEventListener.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/event/def/AbstractFlushingEventListener.java 2006-09-22 01:51:29 UTC (rev 10519)
+++ trunk/Hibernate3/src/org/hibernate/event/def/AbstractFlushingEventListener.java 2006-09-22 01:51:36 UTC (rev 10520)
@@ -113,22 +113,23 @@
final Map.Entry[] list = IdentityMap.concurrentEntries( session.getPersistenceContext().getEntityEntries() );
//safe from concurrent modification because of how entryList() is implemented on IdentityMap
final int size = list.length;
+ final Object anything = getAnything();
for ( int i=0; i<size; i++ ) {
Map.Entry me = list[i];
EntityEntry entry = (EntityEntry) me.getValue();
Status status = entry.getStatus();
if ( status == Status.MANAGED || status == Status.SAVING ) {
- cascadeOnFlush( session, entry.getPersister(), me.getKey() );
+ cascadeOnFlush( session, entry.getPersister(), me.getKey(), anything );
}
}
}
- private void cascadeOnFlush(EventSource session, EntityPersister persister, Object object)
+ private void cascadeOnFlush(EventSource session, EntityPersister persister, Object object, Object anything)
throws HibernateException {
session.getPersistenceContext().incrementCascadeLevel();
try {
new Cascade( getCascadingAction(), Cascade.BEFORE_FLUSH, session )
- .cascade( persister, object, getAnything() );
+ .cascade( persister, object, anything );
}
finally {
session.getPersistenceContext().decrementCascadeLevel();
18 years, 2 months