[hibernate-commits] Hibernate SVN: r10566 - in branches/Lucene_Integration/HibernateExt: . ejb ejb/doc/reference/en ejb/doc/reference/en/modules ejb/lib ejb/src/java/org/hibernate/ejb ejb/src/java/org/hibernate/ejb/connection ejb/src/java/org/hibernate/ejb/event ejb/src/java/org/hibernate/ejb/instrument ejb/src/java/org/hibernate/ejb/packaging ejb/src/java/org/hibernate/ejb/util ejb/src/test ejb/src/test/org/hibernate/ejb/test ejb/src/test/org/hibernate/ejb/test/association ejb/src/test/org/hibernate/ejb/test/cascade ejb/src/test/org/hibernate/ejb/test/emops ejb/src/test/org/hibernate/ejb/test/exception ejb/src/test/org/hibernate/ejb/test/inheritance ejb/src/test/org/hibernate/ejb/test/pack ejb/src/test/org/hibernate/ejb/test/pack/explicitpar ejb/src/test/org/hibernate/ejb/test/packaging ejb/src/test/org/hibernate/ejb/test/transaction ejb/src/test/org/hibernate/ejb/test/xml ejb/src/test-resources/explicitpar/META-INF ejb-api ejb-api/etc ejb-api/src/javax/persistence ejb-api/src/javax/! persistence/spi metadata metadata/doc/reference/en metadata/doc/reference/en/modules metadata/lib metadata/src/java/org/hibernate/annotationfactory metadata/src/java/org/hibernate/annotations metadata/src/java/org/hibernate/cfg metadata/src/java/org/hibernate/cfg/annotations metadata/src/java/org/hibernate/lucene/event metadata/src/java/org/hibernate/lucene/store metadata/src/java/org/hibernate/reflection/java metadata/src/java/org/hibernate/reflection/java/generics metadata/src/java/org/hibernate/reflection/java/xml metadata/src/java/org/hibernate/type metadata/src/java/org/hibernate/validator metadata/src/java/org/hibernate/validator/event metadata/src/java/org/hibernate/validator/interpolator metadata/src/test metadata/src/test/org/hibernate/lucene/test metadata/src/test/org/hibernate/test/annotations metadata/src/test/org/hibernate/test/annotations/bytecode metadata/src/test/org/hibernate/test/annotations/collectionelement metadata/src/test/org/hibernate/test/annotation! s/duplicatedgenerator metadata/src/test/org/hibernate/test/annotations/entity metadata/src/test/org/hibernate/test/annotations/generics metadata/src/test/org/hibernate/test/annotations/genericsinheritance metadata/src/test/org/hibernate/test/annotations/id metadata/src/test/org/hibernate/test/annotations/identifiercollection

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Oct 11 00:03:47 EDT 2006


Author: epbernard
Date: 2006-10-11 00:01:11 -0400 (Wed, 11 Oct 2006)
New Revision: 10566

Added:
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceProperty.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/package-info.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/package-info.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3ConfigurationObjectFactory.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/util/NamingHelper.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/NoPackageEntity.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/AssociationTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Incident.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/IncidentStatus.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Kitchen.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Oven.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Author.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/CascadeTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/FetchTest2.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Soldier2.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Song.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Student.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Teacher.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Troop2.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Mail.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Fruit.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/InheritanceTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Strawberry.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explicitpar/
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explicitpar/Washer.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/Article.java
   branches/Lucene_Integration/HibernateExt/metadata/lucene.txt
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/CollectionId.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/FilterJoinTable.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/FilterJoinTables.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/ForceDiscriminator.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/ForeignKey.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/WhereJoinTable.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/IdBagBinder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/Environment.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/MessageInterpolator.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolator.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolatorAggerator.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Hammer.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/ProxyBreakingTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Tool.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/hammer.hbm.xml
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/duplicatedgenerator/orm.xml
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/State.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/StateType.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Child.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy1.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy2.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy22.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Parent.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy1.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy2.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy22.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/IdentifierCollectionTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Passport.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Stamp.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Card.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardField.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardKey.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/IdManyToOne.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Project.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Trainee.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Training.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.hbm.xml
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/FinancialAsset.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Parent.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Pool.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/PropertyAsset.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/SwimmingPool.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Building.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/BuildingCompany.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Company.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/Incident.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/IncidentStatus.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/orm.xml
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/orm.xml
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DeepGenericsInheritance.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Dummy.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DummySubclass.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass1.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass2.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass1.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass2.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/Organization.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/PrefixMessageInterpolator.java
   branches/Lucene_Integration/HibernateExt/tools/lib/jtidy-r8-20060801.jar
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/MetaAttributeBinder.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/OracleMetaDataDialect.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/Version.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/JPAConfigurationTask.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DAONewExporter.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/EntityNameFromValueVisitor.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/JavaTypeFromValueVisitor.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/AbstractTreeModel.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/BeanTableModel.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsBrowser.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsCellRenderer.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsTreeModel.java
   branches/Lucene_Integration/HibernateExt/tools/src/templates/dot/
   branches/Lucene_Integration/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/dot/tablegraph.dot.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/meta.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/UnionSubclass.hbm.xml
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Aliens.hbm.xml
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/Group.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/SessionAttribute.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/User.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/UserGroup.hbm.xml
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/ManyToManyTest.java
Removed:
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FlushMode.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/AssociationTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Incident.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/IncidentStatus.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Kitchen.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Oven.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Fruit.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/InheritanceTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Strawberry.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explicitpar/Washer.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolator.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolatorAggerator.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/PackageLevelTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Hammer.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/ProxyBreakingTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Tool.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/hammer.hbm.xml
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/duplicatedgenerator/package-info.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Child.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy1.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy2.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy22.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Parent.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy1.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy2.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy22.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/IdentifierCollectionTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Passport.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Stamp.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Card.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardField.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardKey.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/IdManyToOne.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Project.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/package-info.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/package-info.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DeepGenericsInheritance.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Dummy.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DummySubclass.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass1.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass2.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass1.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass2.java
   branches/Lucene_Integration/HibernateExt/tools/lib/jtidy-r8-21122004.jar
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/EJB3ConfigurationTask.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Version.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/AbstractTreeModel.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/BeanTableModel.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsBrowser.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsCellRenderer.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsTreeModel.java
   branches/Lucene_Integration/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/dot/tablegraph.dot.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/Group.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/SessionAttribute.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/User.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/UserGroup.hbm.xml
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/newformat.reveng.xml
   branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-class.vm
   branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-content.vm
   branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-test.vm
   branches/Lucene_Integration/HibernateExt/tools/src/testsupport/templates/pojo/Pojo.vm
Modified:
   branches/Lucene_Integration/HibernateExt/build.bat
   branches/Lucene_Integration/HibernateExt/ejb-api/build.xml
   branches/Lucene_Integration/HibernateExt/ejb-api/etc/license.txt
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AssociationOverride.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AssociationOverrides.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AttributeOverride.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AttributeOverrides.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Basic.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/CascadeType.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Column.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ColumnResult.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorColumn.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorType.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorValue.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Embeddable.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Embedded.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EmbeddedId.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Entity.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityExistsException.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityListeners.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityManager.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityManagerFactory.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityNotFoundException.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityResult.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityTransaction.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EnumType.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Enumerated.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ExcludeDefaultListeners.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ExcludeSuperclassListeners.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FetchType.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FieldResult.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FlushModeType.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/GeneratedValue.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/GenerationType.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Id.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/IdClass.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Inheritance.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/InheritanceType.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinColumn.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinColumns.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinTable.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Lob.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/LockModeType.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ManyToMany.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ManyToOne.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/MapKey.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/MappedSuperclass.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedNativeQueries.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedNativeQuery.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedQueries.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedQuery.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NoResultException.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NonUniqueResultException.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OneToMany.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OneToOne.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OptimisticLockException.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OrderBy.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Persistence.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContext.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContextType.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContexts.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceException.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceUnit.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceUnits.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostLoad.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostPersist.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostRemove.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostUpdate.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrePersist.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PreRemove.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PreUpdate.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrimaryKeyJoinColumn.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrimaryKeyJoinColumns.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Query.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/QueryHint.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/RollbackException.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SecondaryTable.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SecondaryTables.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SequenceGenerator.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SqlResultSetMapping.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SqlResultSetMappings.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Table.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TableGenerator.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Temporal.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TemporalType.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TransactionRequiredException.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Transient.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/UniqueConstraint.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Version.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/ClassTransformer.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceProvider.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitInfo.java
   branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitTransactionType.java
   branches/Lucene_Integration/HibernateExt/ejb/build.xml
   branches/Lucene_Integration/HibernateExt/ejb/changelog.txt
   branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/master.xml
   branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/architecture.xml
   branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/configuration.xml
   branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/listeners.xml
   branches/Lucene_Integration/HibernateExt/ejb/lib/README.txt
   branches/Lucene_Integration/HibernateExt/ejb/lib/ejb3-persistence.jar
   branches/Lucene_Integration/HibernateExt/ejb/lib/hibernate-annotations.jar
   branches/Lucene_Integration/HibernateExt/ejb/lib/javassist.jar
   branches/Lucene_Integration/HibernateExt/ejb/lib/jboss-archive-browsing.jar
   branches/Lucene_Integration/HibernateExt/ejb/readme.txt
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/CurrentEntityManagerImpl.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/EntityManagerImpl.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/HibernatePersistence.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/QueryImpl.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/TransactionImpl.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/Version.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/connection/InjectedDataSourceConnectionProvider.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/BeanCallback.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/CallbackResolver.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/ListenerCallback.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/instrument/InterceptFieldClassFileTransformer.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/FileZippedJarVisitor.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/JarVisitor.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java
   branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/XmlHelper.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test-resources/explicitpar/META-INF/persistence.xml
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/QueryTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/GetReferenceTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/MergeTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Race.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/RemoveTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/exception/ExceptionTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/exception/Music.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/packaging/JarVisitorTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/Book.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/XmlTest.java
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/orm.xml
   branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/orm2.xml
   branches/Lucene_Integration/HibernateExt/metadata/build.xml
   branches/Lucene_Integration/HibernateExt/metadata/changelog.txt
   branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/master.xml
   branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/entity.xml
   branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/lucene.xml
   branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/setup.xml
   branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/validator.xml
   branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/xml-overriding.xml
   branches/Lucene_Integration/HibernateExt/metadata/lib/README.txt
   branches/Lucene_Integration/HibernateExt/metadata/lib/ejb3-persistence.jar
   branches/Lucene_Integration/HibernateExt/metadata/readme.txt
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotationfactory/AnnotationFactory.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Filter.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Filters.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/FlushModeType.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Where.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AbstractPropertyHolder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/BinderHelper.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ClassPropertyHolder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/CollectionPropertyHolder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ComponentPropertyHolder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/CreateKeySecondPass.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3Column.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3DiscriminatorColumn.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3JoinColumn.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ExtendedMappings.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/FkSecondPass.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/IndexColumn.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/IndexSecondPass.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/OneToOneSecondPass.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/PropertyHolder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/PropertyHolderBuilder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ListBinder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/MapBinder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/QueryBinder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/TableBinder.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/Version.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/EJB3OverridenAnnotationReader.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXAnnotatedElement.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXArrayType.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXCollectionType.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/Pair.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/XMLContext.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/ByteArrayBlobType.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/CharacterArrayClobType.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/EnumType.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/ClassValidator.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/MaxValidator.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/MinValidator.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/RangeValidator.java
   branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/event/ValidateEventListener.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages.properties
   branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages_da.properties
   branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages_fr.properties
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/Boy.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/Brand.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/duplicatedgenerator/DuplicateTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/entity/Java5FeaturesTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/Gene.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/Ball.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/Dog.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/IdTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Atmosphere.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/mixed/Document.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/singletable/Building.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/singletable/SingleTableTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Group.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/ManyToManyTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Woman.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Car.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ForestType.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ManyToOneTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/City.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/OneToManyTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/Street.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/Trainer.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/OneToOneTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/override/Trip.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/Dimensions.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/JavaXClassTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/Administration.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/EJB3OverridenAnnotationReaderTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/metadata-complete.xml
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/HibernateAnnotationIntegrationTest.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/Tv.java
   branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/ValidatorTest.java
   branches/Lucene_Integration/HibernateExt/tools/build.xml
   branches/Lucene_Integration/HibernateExt/tools/changelog.txt
   branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/master.xml
   branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/ant.xml
   branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/codegenarchitecture.xml
   branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/plugins.xml
   branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/reverseengineering.xml
   branches/Lucene_Integration/HibernateExt/tools/lib/testlibs/ejb3-persistence.jar
   branches/Lucene_Integration/HibernateExt/tools/lib/testlibs/hibernate-annotations.jar
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCReaderFactory.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DelegatingReverseEngineeringStrategy.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideBinder.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringSettings.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableFilter.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/JDBCMetaDataDialect.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/ResultSetIterator.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/hibernate-reverse-engineering-3.0.dtd
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/ExporterTask.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/GenericExporterTask.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/HibernateToolTask.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/JDBCConfigurationTask.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/AbstractExporter.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DAOExporter.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Exporter.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/GenericExporter.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/HibernateMappingExporter.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/MetaAttributeHelper.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/POJOExporter.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/StringUtils.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateHelper.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateProducer.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/XMLPrettyPrinter.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocHelper.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/jtidy.properties
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/ComponentPOJOClass.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/POJOClass.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/seam/SeamExporter.java
   branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/DefaultValueVisitor.java
   branches/Lucene_Integration/HibernateExt/tools/src/templates/dao/daohome.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/entities/summary.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/index.html
   branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/tables/summary.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/array.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/component.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/id.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/list.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/many-to-one.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/property.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/set.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/timestamp.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/version.hbm.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/pojo/PojoConstructors.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/templates/seam/selector.java.ftl
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/ant/SeamAntTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Constructors.hbm.xml
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenericExporterTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2DaoTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaConstructorTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/XMLPrettyPrinterTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Basic.hbm.xml
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ManyToManyTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/Jdbc2CfgAllTests.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/foreignkeytest.reveng.xml
   branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/overridetest.reveng.xml
   branches/Lucene_Integration/HibernateExt/tools/src/testsupport/NoopReverseEngineeringStrategy.java
   branches/Lucene_Integration/HibernateExt/tools/src/testsupport/anttest-build.xml
Log:
Painful and stupidly complex Merge from trunk
ANN-387 initial work on inheritance

Modified: branches/Lucene_Integration/HibernateExt/build.bat
===================================================================
(Binary files differ)

Modified: branches/Lucene_Integration/HibernateExt/ejb/build.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/build.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/build.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -16,7 +16,7 @@
     <!-- Name of project and version, used to create filenames -->
     <property name="Name" value="Hibernate EntityManager"/>
     <property name="name" value="hibernate-entitymanager"/>
-    <property name="version" value="3.2.0.CR1"/>
+    <property name="version" value="3.2.0.CR3"/>
     <property name="javadoc.packagenames" value="org.hibernate.ejb.*"/>
     <property name="jdbc.dir" value="jdbc"/>
     <property name="copy.test" value="true"/>

Modified: branches/Lucene_Integration/HibernateExt/ejb/changelog.txt
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/changelog.txt	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/changelog.txt	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,6 +1,63 @@
 Hibernate EntityManager Changelog
 ==================================
 
+3.2.0.CR3 (4-10-2006)
+----------------------
+** Bug
+    * [EJB-150] - JarVisitor.addElement does not close passed input streams
+    * [EJB-221] - TransientObjectException with FetchType.LAZY on @ManyToOne and field access on target entity
+    * [EJB-231] - Optimistic locking exception could lead to java.lang.IllegalArgumentException: id to load is required for loading
+
+
+** Improvement
+    * [EJB-234] - Inefficiency during the flush operation
+
+
+3.2.0.CR2 (16-09-2006)
+----------------------
+** Bug
+    * [EJB-98] - EntityManager.find() throws an org.hibernate.ObjectDeletedException if you find something deleted in the same TXA
+    * [EJB-148] - Incorrect exception when @CollectionOfElement is used with @Where and FetchType is EAGER
+    * [EJB-174] - Ejb3Configuration can't open EJB Jar file with persistence.xml in Oracle OC4J server (Jifeng Liu)
+    * [EJB-181] - ExplodedJarVisitor and paths with white spaces
+    * [EJB-185] - Some EJB3 exceptions does not support nested exceptions
+    * [EJB-187] - RuntimeException raised in CallBack methods should be left as is
+    * [EJB-188] - @PostUpdate can be called even if @PreUpdate is not when object is in DELETED state
+    * [EJB-189] - em.getReference() should raise IllegalArgumentException if the id is of the wrong type
+    * [EJB-190] - Query.setParameter() should raise an IllegalArgumentException if the parameter does not exist
+    * [EJB-191] - Incoherent usage of getResultList(), executeUpdate() or getSingleResult() regarding the DML/Select style should raise an IllegalStateException
+    * [EJB-194] - Removing a detached instance is not allowed
+    * [EJB-195] - Wrong query should raise an IllegalArgumentException
+    * [EJB-196] - referencing a transient instance while flushing an association non cascaded should raise IllegalStateException
+    * [EJB-198] - On em.close(), tries to register the transaction even if the transaction is marked for rollback
+    * [EJB-202] - Inaccurate exception message for setFirstResult in QueryImpl
+    * [EJB-203] - exception when using top-level <access>PROPERTY</access> in orm.xml
+    * [EJB-204] - ClassCastException when using <mapped-superclass> in orm.xml
+    * [EJB-205] - refresh() should raise IllegalArgumentException if the entity is not managed
+    * [EJB-207] - em.lock(..., WRITE) raise NPE on some DBs
+    * [EJB-212] - excludeUnlistedClasses ignored in SE case
+    * [EJB-214] - Native Query can not be used with parameter
+    * [EJB-215] - EntityManager fails during transaction commit after it has been closed
+    * [EJB-216] - Query.getSingleResult() whose state-field is null raise an EntityNotFoundException rather than returning null
+    * [EJB-218] - markForRollback() should not swallow the original exception
+    * [EJB-220] - Entity listener documentation contradicts EJB3 specification
+    * [EJB-223] - EntityNotFoundDelegate not Serializable
+
+
+** Improvement
+    * [EJB-82] - Query interface should support parameter lists for positions
+    * [EJB-182] - Add Websphere proprietary jar protocol
+    * [EJB-186] - Set the default cache provider to NoCache to prevent PU misuse to raise exceptions
+    * [EJB-201] - Ejb3Configuration should output a warning if no persistence.xml is found
+    * [EJB-210] - OptimisticLockStrategy should expose the underlying stale entity
+    * [EJB-211] - JavaDoc the EJB 3 API
+
+** New Feature
+    * [EJB-154] - Allow to create/configure an EJB3Configuration without building a sessionfactory
+    * [EJB-160] - Push EJB3Configuration and SessionFactory into JNDI
+    * [EJB-184] - Add EM property for FlushMode
+
+
 3.2.0.CR1 (13-05-2006)
 ----------------------
 ** Bug

Modified: branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/master.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/master.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/master.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -16,7 +16,7 @@
 
     <subtitle>User guide</subtitle>
 
-    <releaseinfo>3.2.0 CR1</releaseinfo>
+    <releaseinfo>3.2.0 CR3</releaseinfo>
 
     <mediaobject>
       <imageobject>

Modified: branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/architecture.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/architecture.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/architecture.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -194,8 +194,8 @@
       entity managers.</para>
 
       <para>In a transaction-scoped container managed entity manager (common
-      case in a J2EE environment), the JTA transaction propagation is the same
-      as the persistence context resource propagation. In other words,
+      case in a Java EE environment), the JTA transaction propagation is the
+      same as the persistence context resource propagation. In other words,
       container-managed transaction-scoped entity managers retrieved within a
       given JTA transaction all share the same persistence context. In
       Hibernate terms, this means all managers share the same session.</para>
@@ -246,21 +246,21 @@
     </section>
   </section>
 
-  <section>
-    <title>J2SE environments</title>
+  <section id="architecture-javase" revision="1">
+    <title>Java SE environments</title>
 
-    <para>In a J2SE environment only extented context application-managed
+    <para>In a Java SE environment only extented context application-managed
     entity managers are available. You can retrieve an entity manger using the
     <literal>EntityManagerFactory</literal> API. Only resource-local entity
     managers are available. In other words, JTA transactions and persistence
-    context propagation are not supported in J2SE (you will have to propagate
-    the persistence context yourself, e.g. using the thread local session
-    pattern popular in the Hibernate community).</para>
+    context propagation are not supported in Java SE (you will have to
+    propagate the persistence context yourself, e.g. using the thread local
+    session pattern popular in the Hibernate community).</para>
 
     <para>Extended context means that a persistence context is created when
     the entity manager is retrieved (using
-    <literal>EntityManagerFactory.createEntityManager(EXTENDED)</literal> )
-    and closed when the entity manager is closed. Many resource-local
-    transaction share the same persistence context, in this case.</para>
+    <literal>EntityManagerFactory.createEntityManager(...)</literal> ) and
+    closed when the entity manager is closed. Many resource-local transaction
+    share the same persistence context, in this case.</para>
   </section>
 </chapter>
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/configuration.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/configuration.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/configuration.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -5,13 +5,14 @@
   <section>
     <title>Setup</title>
 
-    <para>The EJB3 compatible Hibernate EntityManager is built on top of
-    Hibernate core and Hibernate Annotations. You have to use compatible
-    versions of each module. This version is known to work on Hibernate
-    3.2.0.CR2 and Hibernate Annotations 3.2.0.CR1. The following libraries
-    have to be in your classpath: hibernate3.jar, hibernate-annotations.jar,
-    hibernate-entity-manager.jar and all needed third party libraries for each
-    package.(incl. ejb-persistence.jar).</para>
+    <para>The EJB 3.0 / JPA compatible Hibernate EntityManager is built on top
+    of Hibernate core and Hibernate Annotations. You have to use compatible
+    versions of each module. This version is known to work on Hibernate Core
+    3.2.0.CR5 (and 3.2.0.GA at the time of writing) and Hibernate Annotations
+    3.2.0.CR3. The following libraries have to be in your classpath:
+    hibernate3.jar, hibernate-annotations.jar, hibernate-entitymanager.jar and
+    all needed third party libraries for each package.(incl.
+    ejb-persistence.jar).</para>
   </section>
 
   <section id="setup-configuration"
@@ -431,7 +432,7 @@
      .addClass( NonAnnotatedClass.class ) //add an hbm.xml file using the Hibernate convention
      .addRerousce( "mypath/MyOtherCLass.hbm.xml ) //add an hbm.xml file
      .addRerousce( "mypath/orm.xml ) //add an EJB3 deployment descriptor
-     .createEntityManagerFactory(); //Create the entity manager factory</programlisting>
+     .buildEntityManagerFactory(); //Create the entity manager factory</programlisting>
     </section>
   </section>
 
@@ -577,7 +578,7 @@
   </section>
 
   <section>
-    <title>Obtaining an EntityManager in a J2SE environment</title>
+    <title>Obtaining an EntityManager in a Java SE environment</title>
 
     <para>An entity manager factory should be considered as an immutable
     configuration holder, it is defined to point to a single datasource and to

Modified: branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/listeners.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/listeners.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/doc/reference/en/modules/listeners.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<chapter id="lsiteners">
+<chapter id="listeners">
   <title>Entity listeners and Callback methods</title>
 
   <section>
@@ -64,7 +64,7 @@
     have two methods being annotated by the same callback annotation whether
     it is a callback method or an entity listener method. A callback method is
     a no-arg method with no return type and any arbitrary name. An entity
-    listener has the signature public <code>void &lt;METHOD&gt;(Object)</code>
+    listener has the signature <code>void &lt;METHOD&gt;(Object)</code>
     where Object is of the actual entity type (note that Hibernate Entity
     Manager relaxed this constraint and allows <literal>Object</literal> of
     <literal>java.lang.Object</literal> type (allowing sharing of listeners

Modified: branches/Lucene_Integration/HibernateExt/ejb/lib/README.txt
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/lib/README.txt	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/lib/README.txt	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,7 +1,7 @@
 Hibernate Metadata dependencies
 ===============================
 
-ejb3-persistence (proposed final draft): required
-hibernate-annotations (3.1beta9): required
-javassist (3.1): required
-jboss-archive-browsing (5.0.0alpha build: CVSTag=HEAD date=200507071617): required
+ejb3-persistence (final release): required
+hibernate-annotations: required
+javassist (3.3): required
+jboss-archive-browsing (5.0.0alpha build: CVSTag=HEAD date=200607201 119): required

Modified: branches/Lucene_Integration/HibernateExt/ejb/lib/ejb3-persistence.jar
===================================================================
(Binary files differ)

Modified: branches/Lucene_Integration/HibernateExt/ejb/lib/hibernate-annotations.jar
===================================================================
(Binary files differ)

Modified: branches/Lucene_Integration/HibernateExt/ejb/lib/javassist.jar
===================================================================
(Binary files differ)

Modified: branches/Lucene_Integration/HibernateExt/ejb/lib/jboss-archive-browsing.jar
===================================================================
(Binary files differ)

Modified: branches/Lucene_Integration/HibernateExt/ejb/readme.txt
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/readme.txt	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/readme.txt	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,9 @@
 Hibernate EntityManager
 ==================================================
-Version: 3.2.0.CR1, 13.05.2006
+Version: 3.2.0.CR3, 4.10.2006
 
-THIS RELEASE OF HIBERNATE ENTITYMANAGER REQUIRES HIBERNATE 3.2.0.CR2 AND DOES
-NOT WORK WITH HIBERNATE 3.1.x OR ANY OLDER VERSION OF HIBERNATE.
+THIS RELEASE OF HIBERNATE ENTITYMANAGER REQUIRES HIBERNATE CORE 3.2.0.CR5 AND 
+DOES NOT WORK WITH HIBERNATE 3.1.x OR ANY OLDER VERSION OF HIBERNATE.
 
 
 Description

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -44,6 +44,7 @@
 import org.hibernate.TypeMismatchException;
 import org.hibernate.QueryException;
 import org.hibernate.TransientObjectException;
+import org.hibernate.StaleObjectStateException;
 import org.hibernate.ejb.transaction.JoinableCMTTransaction;
 import org.hibernate.ejb.util.ConfigurationHelper;
 import org.hibernate.engine.SessionFactoryImplementor;
@@ -299,8 +300,17 @@
 		}
 	}
 
+	/**
+	 * return a Session
+	 * @throws IllegalStateException if the entity manager is closed
+	 */
 	public abstract Session getSession();
 
+	/**
+	 * Return a Session (even if the entity manager is closed
+	 */
+	protected abstract Session getRawSession();
+
 	public EntityTransaction getTransaction() {
 		if ( transactionType == PersistenceUnitTransactionType.JTA ) {
 			throw new IllegalStateException( "JTA EntityManager cannot access a transactions" );
@@ -400,7 +410,7 @@
 	}
 
 	public boolean isTransactionInProgress() {
-		return ( (SessionImplementor) getSession() ).isTransactionInProgress();
+		return ( (SessionImplementor) getRawSession() ).isTransactionInProgress();
 	}
 
 	protected void markAsRollback() {
@@ -409,9 +419,10 @@
 			tx.setRollbackOnly();
 		}
 		else {
+			//no explicit use of the tx. boudaries methods
 			if ( PersistenceUnitTransactionType.JTA == transactionType ) {
 				TransactionManager transactionManager =
-						( (SessionFactoryImplementor) getSession().getSessionFactory() ).getTransactionManager();
+						( (SessionFactoryImplementor) getRawSession().getSessionFactory() ).getTransactionManager();
 				if ( transactionManager == null ) {
 					throw new PersistenceException(
 							"Using a JTA persistence context wo setting hibernate.transaction.manager_lookup_class"
@@ -441,7 +452,7 @@
 				final Transaction transaction = session.getTransaction();
 				if ( transaction != null && transaction instanceof JoinableCMTTransaction ) {
 					//can't handle it if not a joinnable transaction
-					final JoinableCMTTransaction joinableCMTTransaction = (JoinableCMTTransaction) session.getTransaction();
+					final JoinableCMTTransaction joinableCMTTransaction = (JoinableCMTTransaction) transaction;
 
 					if ( joinableCMTTransaction.getStatus() == JoinableCMTTransaction.JoinStatus.JOINED ) {
 						log.debug( "Transaction already joined" );
@@ -571,13 +582,40 @@
 	}
 
 	public void throwPersistenceException(PersistenceException e) {
-		if ( ! ( e instanceof NoResultException || ( e instanceof NonUniqueResultException ) ) ) markAsRollback();
+		if ( ! ( e instanceof NoResultException || ( e instanceof NonUniqueResultException ) ) ) {
+			try {
+				markAsRollback();
+			}
+			catch (Exception ne) {
+				//we do not want the subsequent exception to swallow the original one
+				log.error( "Unable to mark for rollback on PersistenceException: ", ne);
+			}
+		}
 		throw e;
 	}
 
 	public void throwPersistenceException(HibernateException e) {
 		if ( e instanceof StaleStateException ) {
-			throwPersistenceException( new OptimisticLockException( e ) );
+			if ( e instanceof StaleObjectStateException ) {
+				StaleObjectStateException sose = (StaleObjectStateException) e;
+				Serializable identifier = sose.getIdentifier();
+				if (identifier != null) {
+					Object entity = getRawSession().load( sose.getEntityName(), identifier );
+					if ( entity instanceof Serializable ) {
+						//avoid some user errors regarding boundary crossing
+						throwPersistenceException( new OptimisticLockException(	null, e, entity ) );
+					}
+					else {
+						throwPersistenceException( new OptimisticLockException( e ) );
+					}
+				}
+				else {
+					throwPersistenceException( new OptimisticLockException( e ) );
+				}
+			}
+			else {
+				throwPersistenceException( new OptimisticLockException( e ) );
+			}
 		}
 		else if ( e instanceof ConstraintViolationException ) {
 			//FIXME this is bad cause ConstraintViolationException happens in other circumstances
@@ -596,7 +634,13 @@
 			throw new IllegalArgumentException( e );
 		}
 		else if ( e instanceof TransientObjectException ) {
-			markAsRollback();
+			try {
+				markAsRollback();
+			}
+			catch (Exception ne) {
+				//we do not want the subsequent exception to swallow the original one
+				log.error( "Unable to mark for rollback on TransientObjectException: ", ne);
+			}
 			throw new IllegalStateException( e ); //Spec 3.2.3 Synchronization rules
 		}
 		else {

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/CurrentEntityManagerImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/CurrentEntityManagerImpl.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/CurrentEntityManagerImpl.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -45,6 +45,10 @@
 		return s;
 	}
 
+	protected Session getRawSession() {
+		return getSession();
+	}
+
 	public void close() {
 		throw new UnsupportedOperationException( "cannot close the JTA-bound EntityManager" );
 	}
@@ -53,7 +57,7 @@
 		//TODO Hum contradictory comments, I'm getting mad
 		//no need to force enlistment in the tx, a current session is always enlisted
 		//adjustFlushMode(); //don't adjust, can't be done on closed EM
-		getSession().isOpen(); //to force enlistment in tx
+		getRawSession().isOpen(); //to force enlistment in tx
 		return true;
 	}
 

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,10 +2,13 @@
 package org.hibernate.ejb;
 
 import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.net.URL;
 import java.util.ArrayList;
@@ -19,6 +22,10 @@
 import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
+import javax.naming.BinaryRefAddr;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
 import javax.persistence.Embeddable;
 import javax.persistence.Entity;
 import javax.persistence.EntityManagerFactory;
@@ -39,6 +46,7 @@
 import org.hibernate.HibernateException;
 import org.hibernate.Interceptor;
 import org.hibernate.MappingException;
+import org.hibernate.MappingNotFoundException;
 import org.hibernate.SessionFactory;
 import org.hibernate.cfg.AnnotationConfiguration;
 import org.hibernate.cfg.Configuration;
@@ -54,6 +62,7 @@
 import org.hibernate.ejb.transaction.JoinableCMTTransactionFactory;
 import org.hibernate.ejb.util.ConfigurationHelper;
 import org.hibernate.ejb.util.LogHelper;
+import org.hibernate.ejb.util.NamingHelper;
 import org.hibernate.engine.FilterDefinition;
 import org.hibernate.event.EventListeners;
 import org.hibernate.mapping.AuxiliaryDatabaseObject;
@@ -71,33 +80,53 @@
 import org.xml.sax.SAXException;
 
 /**
+ * Allow a fine tuned configuration of an EJB 3.0 EntityManagerFactory
+ *
+ * A Ejb3Configuration object is only guaranteed to create one EntityManagerFactory.
+ * Multiple usage of #buildEntityManagerFactory() is not guaranteed.
+ *
+ * After #buildEntityManagerFactory() has been called, you no longer can change the configuration
+ * state (no class adding, no property change etc)
+ *
+ * When serialized / deserialized or retrieved from the JNDI, you no longer can change the
+ * configuration state (no class adding, no property change etc)
+ *
+ * Putting the configuration in the JNDI is an expensive operation that requires a partial
+ * serialization
+ *
  * @author Emmanuel Bernard
  */
-public class Ejb3Configuration implements Serializable {
+public class Ejb3Configuration implements Serializable, Referenceable {
 	private static final String IMPLEMENTATION_NAME = HibernatePersistence.class.getName();
+	private static final String META_INF_ORM_XML = "META-INF/orm.xml";
 	private static Log log = LogFactory.getLog( Ejb3Configuration.class );
+	private static EntityNotFoundDelegate ejb3EntityNotFoundDelegate = new Ejb3EntityNotFoundDelegate();
 
+	private static class Ejb3EntityNotFoundDelegate implements EntityNotFoundDelegate, Serializable {
+		public void handleEntityNotFound(String entityName, Serializable id) {
+			throw new EntityNotFoundException("Unable to find " + entityName  + " with id " + id);
+		}
+	}
+
 	static {
 		Version.touch();
 	}
 
 	private AnnotationConfiguration cfg;
 	private SettingsFactory settingsFactory;
-	private EventListenerConfigurator listenerConfigurator;
+	//made transient and not restored in deserialization on purpose, should no longer be called after restoration
+	private transient EventListenerConfigurator listenerConfigurator;
 	private PersistenceUnitTransactionType transactionType;
-	private static final String META_INF_ORM_XML = "META-INF/orm.xml";
+	private boolean discardOnClose;
+	//made transient and not restored in deserialization on purpose, should no longer be called after restoration
+	private transient ClassLoader overridenClassLoader;
 
+
 	public Ejb3Configuration() {
 		settingsFactory = new InjectionSettingsFactory();
 		cfg = new AnnotationConfiguration( settingsFactory );
-		cfg.setEntityNotFoundDelegate( new EntityNotFoundDelegate() {
-
-			public void handleEntityNotFound(String entityName, Serializable id) {
-				throw new EntityNotFoundException("Unable to find " + entityName  + " with id " + id);
-			}
-		} );
+		cfg.setEntityNotFoundDelegate( ejb3EntityNotFoundDelegate );
 		listenerConfigurator = new EventListenerConfigurator( this );
-		//transactionType = PersistenceUnitTransactionType.JTA; //default as per the spec
 	}
 
 	/**
@@ -116,8 +145,9 @@
 
 	/**
 	 * create a factory from a parsed persistence.xml
+	 * Especially the scanning of classes and additional jars is done already at this point.
 	 */
-	private EntityManagerFactory createFactory(PersistenceMetadata metadata, Map overrides) {
+	private Ejb3Configuration configure(PersistenceMetadata metadata, Map overrides) {
 		log.debug( "Creating Factory: " + metadata.getName() );
 
 		Map workingVars = new HashMap();
@@ -145,27 +175,32 @@
 		Properties props = new Properties();
 		props.putAll( metadata.getProps() );
 		if ( overrides != null ) props.putAll( overrides ); //yuk!
-		return createEntityManagerFactory( props, workingVars );
+		configure( props, workingVars );
+		return this;
 	}
 
 	/**
-	 * Get an entity manager factory by its entity manager name and given the
+	 * Build the configuration from an entity manager name and given the
 	 * appropriate extra properties. Those properties override the one get through
 	 * the peristence.xml file.
+	 * If the persistence unit name is not found or does not match the Persistence Provider, null is returned
 	 *
-	 * @param emName	  entity manager name
+	 * @param persistenceUnitName persistence unit name
 	 * @param integration properties passed to the persistence provider
-	 * @return initialized EntityManagerFactory
+	 * @return configured Ejb3Configuration or null if no persistence unit match
 	 */
-	public EntityManagerFactory createEntityManagerFactory(String emName, Map integration) {
+	public Ejb3Configuration configure(String persistenceUnitName, Map integration) {
 		try {
-			log.debug( "Trying to find persistence unit: " + emName );
+			log.debug( "Look up for persistence unit: " + persistenceUnitName );
 			integration = integration == null ?
-					integration = CollectionHelper.EMPTY_MAP :
+					CollectionHelper.EMPTY_MAP :
 					Collections.unmodifiableMap( integration );
 			Enumeration<URL> xmls = Thread.currentThread()
 					.getContextClassLoader()
 					.getResources( "META-INF/persistence.xml" );
+			if ( ! xmls.hasMoreElements() ) {
+				log.info( "Could not find any META-INF/persistence.xml file in the classpath");
+			}
 			while ( xmls.hasMoreElements() ) {
 				URL url = xmls.nextElement();
 				log.trace( "Analyse of persistence.xml: " + url );
@@ -175,31 +210,29 @@
 						cfg.getEntityResolver()
 				);
 				for ( PersistenceMetadata metadata : metadataFiles ) {
-					JarVisitor.Filter[] filters = getFilters( metadata.getProps(), integration, metadata.getMappingFiles() );
+					log.trace( metadata.toString() );
 
 					if ( metadata.getProvider() == null || IMPLEMENTATION_NAME.equalsIgnoreCase(
 							metadata.getProvider()
 					) ) {
-						log.trace( "Archive to be processed by hibernate Entity Manager implementation found" );
 						//correct provider
 						URL jarURL = JarVisitor.getJarURLFromURLEntry( url, "/META-INF/persistence.xml" );
-						JarVisitor visitor = JarVisitor.getVisitor( jarURL, filters );
+						JarVisitor.Filter[] persistenceXmlFilter = getFilters( metadata, integration, metadata.getExcludeUnlistedClasses() );
+						JarVisitor visitor = JarVisitor.getVisitor( jarURL, persistenceXmlFilter );
 						if ( metadata.getName() == null ) {
 							metadata.setName( visitor.getUnqualifiedJarName() );
 						}
-						if ( log.isTraceEnabled() ) log.trace( "Persistence unit name: " + metadata.getName() );
-
-						log.trace( "emname:" + emName + " metadata: " + metadata.getName() );
-						if ( emName == null && xmls.hasMoreElements() ) {
+						if ( persistenceUnitName == null && xmls.hasMoreElements() ) {
 							throw new PersistenceException( "No name provided and several persistence units found" );
 						}
-						else if ( emName == null || metadata.getName().equals( emName ) ) {
+						else if ( persistenceUnitName == null || metadata.getName().equals( persistenceUnitName ) ) {
 							addMetadataFromVisitor( visitor, metadata );
+							JarVisitor.Filter[] otherXmlFilter = getFilters( metadata, integration, false );
 							for ( String jarFile : metadata.getJarFiles() ) {
-								visitor = JarVisitor.getVisitor( jarFile, filters );
+								visitor = JarVisitor.getVisitor( jarFile, otherXmlFilter );
 								addMetadataFromVisitor( visitor, metadata );
 							}
-							return createFactory( metadata, integration );
+							return configure( metadata, integration );
 						}
 					}
 				}
@@ -242,9 +275,10 @@
 	}
 
 	/**
-	 * Create a factory from a PersistenceInfo object
+	 * Process configuration from a PersistenceUnitInfo object
+	 * Typically called by the container
 	 */
-	public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map integration) {
+	public Ejb3Configuration configure(PersistenceUnitInfo info, Map integration) {
 		if ( log.isDebugEnabled() ) {
 			log.debug( "Processing " + LogHelper.logPersistenceUnitInfo( info ) );
 		}
@@ -267,10 +301,14 @@
 		//set the classloader
 		Thread thread = Thread.currentThread();
 		ClassLoader contextClassLoader = thread.getContextClassLoader();
-		if ( ! info.getClassLoader().equals( contextClassLoader ) ) {
-			thread.setContextClassLoader( info.getClassLoader() );
+		boolean sameClassLoader = info.getClassLoader().equals( contextClassLoader );
+		if ( ! sameClassLoader ) {
+			overridenClassLoader = info.getClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
 		}
-		EntityManagerFactory entityManagerFactory;
+		else {
+			overridenClassLoader = null;
+		}
 
 		try {
 			Map workingVars = new HashMap();
@@ -294,21 +332,21 @@
 			defineTransactionType( transactionType, workingVars );
 			//		}
 			//workingVars.put( HibernatePersistence.TRANSACTION_TYPE, transactionType );
-			boolean[] detectArtifact = getDetectedArtifacts( info.getProperties(), null );
+			boolean[] detectArtifactForOtherJars = getDetectedArtifacts( info.getProperties(), null, false );
+			boolean[] detectArtifactForMainJar = getDetectedArtifacts( info.getProperties(), null, info.excludeUnlistedClasses() );
 			for ( URL jar : info.getJarFileUrls() ) {
-				if ( detectArtifact[0] ) scanForClasses( jar, packages, entities );
-				if ( detectArtifact[1] ) scanForHbmXmlFiles( jar, hbmFiles );
+				if ( detectArtifactForOtherJars[0] ) scanForClasses( jar, packages, entities );
+				if ( detectArtifactForOtherJars[1] ) scanForHbmXmlFiles( jar, hbmFiles );
 			}
-			if ( ! info.excludeUnlistedClasses() ) {
-				if ( detectArtifact[0] ) scanForClasses( info.getPersistenceUnitRootUrl(), packages, entities );
-				if ( detectArtifact[1] ) scanForHbmXmlFiles( info.getPersistenceUnitRootUrl(), hbmFiles );
-			}
+			if ( detectArtifactForMainJar[0] ) scanForClasses( info.getPersistenceUnitRootUrl(), packages, entities );
+			if ( detectArtifactForMainJar[1] ) scanForHbmXmlFiles( info.getPersistenceUnitRootUrl(), hbmFiles );
 
 			Properties properties = info.getProperties() != null ?
 					info.getProperties() :
 					new Properties();
 			ConfigurationHelper.overrideProperties( properties, integration );
 
+			//FIXME entities is used to enhance classes and to collect annotated entities this should not be mixed
 			//fill up entities with the on found in xml files
 			addXMLEntities( xmlFiles, info, entities );
 
@@ -344,15 +382,15 @@
 				);
 			}
 
-			entityManagerFactory = createEntityManagerFactory( properties, workingVars );
+			configure( properties, workingVars );
 		}
 		finally {
 			//After EMF, set the CCL back
-			if ( ! info.getClassLoader().equals( contextClassLoader ) ) {
+			if ( ! sameClassLoader ) {
 				thread.setContextClassLoader( contextClassLoader );
 			}
 		}
-		return entityManagerFactory;
+		return this;
 	}
 
 	private void addXMLEntities(List<String> xmlFiles, PersistenceUnitInfo info, List<String> entities) {
@@ -414,7 +452,7 @@
 					}
 				}
 				else if ( rootElement != null && "hibernate-mappings".equals( rootElement.getName() ) ) {
-					//TODO
+					//FIXME include hbm xml entities to enhance them but entities is also used to collect annotated entities
 				}
 			}
 			catch (DocumentException e) {
@@ -458,7 +496,7 @@
 		return this;
 	}
 
-	private boolean[] getDetectedArtifacts(Properties properties, Map overridenProperties) {
+	private boolean[] getDetectedArtifacts(Properties properties, Map overridenProperties, boolean excludeIfNotOverriden) {
 		boolean[] result = new boolean[2];
 		result[0] = false; //detect classes
 		result[1] = false; //detect hbm
@@ -466,9 +504,16 @@
 				(String) overridenProperties.get( HibernatePersistence.AUTODETECTION ) :
 				null;
 		detect = detect == null ?
-				properties.getProperty( HibernatePersistence.AUTODETECTION, "class,hbm" ) :
+				properties.getProperty( HibernatePersistence.AUTODETECTION) :
 				detect;
-		StringTokenizer st = new StringTokenizer( detect, ",", false );
+		if (detect == null && excludeIfNotOverriden) {
+			//not overriden so we comply with the spec
+			return result;
+		}
+		else if (detect == null){
+			detect = "class,hbm";
+		}
+		StringTokenizer st = new StringTokenizer( detect, ", ", false );
 		while ( st.hasMoreElements() ) {
 			String element = (String) st.nextElement();
 			if ( "class".equalsIgnoreCase( element ) ) result[0] = true;
@@ -478,9 +523,12 @@
 		return result;
 	}
 
-	private JarVisitor.Filter[] getFilters(Properties properties, Map overridenProperties, final List<String> mappingFiles) {
-		boolean[] result = getDetectedArtifacts( properties, overridenProperties );
-		int size = ( result[0] ? 2 : 0 ) + 1; //( result[1] ? 1 : 0 );
+	private JarVisitor.Filter[] getFilters(PersistenceMetadata metadata, Map overridenProperties, boolean excludeIfNotOverriden) {
+		Properties properties = metadata.getProps();
+		final List<String> mappingFiles = metadata.getMappingFiles();
+		boolean[] result = getDetectedArtifacts( properties, overridenProperties, excludeIfNotOverriden );
+
+		int size = ( result[0] ? 2 : 0 ) + 1; //class involves classes and packages, xml files are always involved because of orm.xml
 		JarVisitor.Filter[] filters = new JarVisitor.Filter[size];
 		if ( result[0] ) {
 			filters[0] = new JarVisitor.PackageFilter( false, null ) {
@@ -604,6 +652,7 @@
 	 * HibernatePersistence.LOADED_CLASSES -> Collection<Class> (list of loaded classes)
 	 * <p/>
 	 * <b>Used by JBoss AS only</b>
+	 * @deprecated use the Java Persistence API
 	 */
 	// This is used directly by JBoss so don't remove until further notice.  bill at jboss.org
 	public EntityManagerFactory createEntityManagerFactory(Map workingVars) {
@@ -616,28 +665,76 @@
 			props.remove( HibernatePersistence.HBXML_FILES );
 			props.remove( HibernatePersistence.LOADED_CLASSES );
 		}
-		return createEntityManagerFactory( props, workingVars );
+		configure( props, workingVars );
+		return buildEntityManagerFactory();
 	}
 
 	/**
-	 * Create an EntityManagerFactory <b>when</b> the configuration is ready
+	 * Process configuration and build an EntityManagerFactory <b>when</b> the configuration is ready
+	 * @deprecated
 	 */
 	public EntityManagerFactory createEntityManagerFactory() {
-		return createEntityManagerFactory( cfg.getProperties(), new HashMap() );
+		configure( cfg.getProperties(), new HashMap() );
+		return buildEntityManagerFactory();
 	}
 
-	private EntityManagerFactory buildEntityManagerFactory(boolean discardOnClose) {
-		return new EntityManagerFactoryImpl(
-				cfg.buildSessionFactory(),
-				transactionType,
-				discardOnClose
+	public EntityManagerFactory buildEntityManagerFactory() {
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			NamingHelper.bind(this);
+			return new EntityManagerFactoryImpl(
+					cfg.buildSessionFactory(),
+					transactionType,
+					discardOnClose
+			);
+		}
+		catch (HibernateException e) {
+			throw new PersistenceException( e );
+		}
+		finally {
+			if (thread != null) {
+				thread.setContextClassLoader( contextClassLoader );
+			}
+		}
+	}
+
+	public Reference getReference() throws NamingException {
+		log.debug("Returning a Reference to the Ejb3Configuration");
+		ByteArrayOutputStream stream = new ByteArrayOutputStream();
+		ObjectOutput out = null;
+		byte[] serialized;
+		try {
+			out = new ObjectOutputStream( stream );
+			out.writeObject( this );
+			out.close();
+			serialized = stream.toByteArray();
+			stream.close();
+		}
+		catch (IOException e) {
+			NamingException namingException = new NamingException( "Unable to serialize Ejb3Configuration" );
+			namingException.setRootCause( e );
+			throw namingException;
+		}
+
+		return new Reference(
+				Ejb3Configuration.class.getName(),
+				new BinaryRefAddr("object", serialized ),
+				Ejb3ConfigurationObjectFactory.class.getName(),
+				null
 		);
 	}
 
 	/**
 	 * create a factory from a canonical workingVars map and the overriden properties
+	 *
 	 */
-	private EntityManagerFactory createEntityManagerFactory(
+	private Ejb3Configuration configure(
 			Properties properties, Map workingVars
 	) {
 		Properties preparedProperties = prepareProperties( properties, workingVars );
@@ -754,9 +851,9 @@
 		if ( ! "true".equalsIgnoreCase( cfg.getProperty( Environment.AUTOCOMMIT ) ) ) {
 			log.warn( Environment.AUTOCOMMIT + " = false break the EJB3 specification" );
 		}
-		boolean discardOnClose = preparedProperties.getProperty( HibernatePersistence.DISCARD_PC_ON_CLOSE )
+		discardOnClose = preparedProperties.getProperty( HibernatePersistence.DISCARD_PC_ON_CLOSE )
 				.equals( "true" );
-		return buildEntityManagerFactory( discardOnClose );
+		return this;
 	}
 
 	private void addClassesToSessionFactory(Map workingVars) {
@@ -790,7 +887,7 @@
 					if ( xmlFile.endsWith( META_INF_ORM_XML ) ) useMetaInf = true;
 					cfg.addResource( xmlFile );
 				}
-				catch( MappingException me ) {
+				catch( MappingNotFoundException e ) {
 					if ( ! xmlFile.endsWith( META_INF_ORM_XML ) ) {
 						throw new PersistenceException( getExceptionHeader(workingVars)
 								+ "Unable to find XML mapping file in classpath: " + xmlFile);
@@ -800,6 +897,10 @@
 						//swallow it, the META-INF/orm.xml is optional
 					}
 				}
+				catch( MappingException me ) {
+					throw new PersistenceException( getExceptionHeader(workingVars)
+								+ "Error while reading JPA XML file: " + xmlFile, me);
+				}
 				if ( log.isInfoEnabled() ) {
 					if ( Boolean.TRUE.equals( useMetaInf ) ) {
 						log.info( getExceptionHeader( workingVars ) + META_INF_ORM_XML + " found");
@@ -815,6 +916,7 @@
 					HibernatePersistence.HBXML_FILES
 			);
 			for ( InputStream is : hbmXmlFiles ) {
+				//addInputStream has the responsibility to close the stream
 				cfg.addInputStream( is );
 			}
 		}
@@ -973,7 +1075,19 @@
 
 
 	public Settings buildSettings() throws HibernateException {
-		return settingsFactory.buildSettings( cfg.getProperties() );
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			return settingsFactory.buildSettings( cfg.getProperties() );
+		}
+		finally {
+			if (thread != null) thread.setContextClassLoader( contextClassLoader );
+		}
 	}
 
 	public Ejb3Configuration addProperties(Properties props) {
@@ -982,41 +1096,139 @@
 	}
 
 	public Ejb3Configuration addAnnotatedClass(Class persistentClass) throws MappingException {
-		cfg.addAnnotatedClass( persistentClass );
-		return this;
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			cfg.addAnnotatedClass( persistentClass );
+			return this;
+		}
+		finally {
+			if (thread != null) thread.setContextClassLoader( contextClassLoader );
+		}
 	}
 
 	public Ejb3Configuration configure(String resource) throws HibernateException {
-		cfg.configure( resource );
-		return this;
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			Properties properties = new Properties();
+			properties.setProperty( HibernatePersistence.CFG_FILE, resource);
+			configure( properties, new HashMap() );
+			return this;
+		}
+		finally {
+			if (thread != null) thread.setContextClassLoader( contextClassLoader );
+		}
 	}
 
 	public Ejb3Configuration addPackage(String packageName) throws MappingException {
-		cfg.addPackage( packageName );
-		return this;
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			cfg.addPackage( packageName );
+			return this;
+		}
+		finally {
+			if (thread != null) thread.setContextClassLoader( contextClassLoader );
+		}
 	}
 
 	public Ejb3Configuration addFile(String xmlFile) throws MappingException {
-		cfg.addFile( xmlFile );
-		return this;
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			cfg.addFile( xmlFile );
+			return this;
+		}
+		finally {
+			if (thread != null) thread.setContextClassLoader( contextClassLoader );
+		}
 	}
 
 	public Ejb3Configuration addClass(Class persistentClass) throws MappingException {
-		cfg.addClass( persistentClass );
-		return this;
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			cfg.addClass( persistentClass );
+			return this;
+		}
+		finally {
+			if (thread != null) thread.setContextClassLoader( contextClassLoader );
+		}
 	}
 
 	public Ejb3Configuration addFile(File xmlFile) throws MappingException {
-		cfg.addFile( xmlFile );
-		return this;
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			cfg.addFile( xmlFile );
+			return this;
+		}
+		finally {
+			if (thread != null) thread.setContextClassLoader( contextClassLoader );
+		}
 	}
 
 	public void buildMappings() {
-		cfg.buildMappings();
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			cfg.buildMappings();
+		}
+		finally {
+			if (thread != null) thread.setContextClassLoader( contextClassLoader );
+		}
 	}
 
 	public Iterator getClassMappings() {
-		return cfg.getClassMappings();
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			return cfg.getClassMappings();
+		}
+		finally {
+			if (thread != null) thread.setContextClassLoader( contextClassLoader );
+		}
 	}
 
 	public EventListeners getEventListeners() {
@@ -1106,13 +1318,37 @@
 	}
 
 	public Ejb3Configuration addInputStream(InputStream xmlInputStream) throws MappingException {
-		cfg.addInputStream( xmlInputStream );
-		return this;
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			cfg.addInputStream( xmlInputStream );
+			return this;
+		}
+		finally {
+			if (thread != null) thread.setContextClassLoader( contextClassLoader );
+		}
 	}
 
 	public Ejb3Configuration addResource(String path) throws MappingException {
-		cfg.addResource( path );
-		return this;
+		Thread thread = null;
+		ClassLoader contextClassLoader = null;
+		if (overridenClassLoader != null) {
+			thread = Thread.currentThread();
+			contextClassLoader = thread.getContextClassLoader();
+			thread.setContextClassLoader( overridenClassLoader );
+		}
+		try {
+			cfg.addResource( path );
+			return this;
+		}
+		finally {
+			if (thread != null) thread.setContextClassLoader( contextClassLoader );
+		}
 	}
 
 	public Ejb3Configuration addResource(String path, ClassLoader classLoader) throws MappingException {

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3ConfigurationObjectFactory.java (from rev 10565, trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3ConfigurationObjectFactory.java)

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/EntityManagerImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/EntityManagerImpl.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/EntityManagerImpl.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -40,16 +40,17 @@
 	public Session getSession() {
 
 		if ( !open ) throw new IllegalStateException( "EntityManager is closed" );
+		return getRawSession();
+	}
 
+	protected Session getRawSession() {
 		if ( session == null ) {
 			session = sessionFactory.openSession();
 			if ( persistenceContextType == PersistenceContextType.TRANSACTION ) {
 				( (SessionImplementor) session ).setAutoClear( true );
 			}
 		}
-
 		return session;
-
 	}
 
 	public void close() {
@@ -64,7 +65,6 @@
 						}
 
 						public void afterCompletion(int i) {
-							//TODO should I check for isOpen() ?
 							if ( session != null ) {
 								if ( session.isOpen() ) {
 									log.debug( "Closing entity manager after transaction completion" );

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/HibernatePersistence.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/HibernatePersistence.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/HibernatePersistence.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -34,21 +34,6 @@
 	 */
 	public static final String AUTODETECTION = "hibernate.archive.autodetection";
 	/**
-	 * List of classes names
-	 * Internal use only
-	 */
-	public static final String CLASS_NAMES = "hibernate.ejb.classes";
-	/**
-	 * List of annotated packages
-	 * Internal use only
-	 */
-	public static final String PACKAGE_NAMES = "hibernate.ejb.packages";
-	/**
-	 * List of classes names
-	 * Internal use only
-	 */
-	public static final String XML_FILE_NAMES = "hibernate.ejb.xml_files";
-	/**
 	 * cfg.xml configuration file used
 	 */
 	public static final String CFG_FILE = "hibernate.ejb.cfgfile";
@@ -86,12 +71,33 @@
 	 * The EJB3 compliant and default choice is false
 	 */
 	public static final String DISCARD_PC_ON_CLOSE = "hibernate.ejb.discard_pc_on_close";
+	/**
+	 * Consider this as experimental
+	 * It is not recommended to set up this property, the configuration is stored
+	 * in the JNDI in a serialized form
+	 */
+	public static final String CONFIGURATION_JNDI_NAME = "hibernate.ejb.configuration_jndi_name";
 
 	//The following properties are for Internal use only
 	/**
 	 * link to the alternative Hibernate configuration file
 	 * Internal use only
 	 */
+	/**
+	 * List of classes names
+	 * Internal use only
+	 */
+	public static final String CLASS_NAMES = "hibernate.ejb.classes";
+	/**
+	 * List of annotated packages
+	 * Internal use only
+	 */
+	public static final String PACKAGE_NAMES = "hibernate.ejb.packages";
+	/**
+	 * List of classes names
+	 * Internal use only
+	 */
+	public static final String XML_FILE_NAMES = "hibernate.ejb.xml_files";
 	public static final String HBXML_FILES = "hibernate.hbmxml.files";
 	public static final String LOADED_CLASSES = "hibernate.ejb.loaded.classes";
 	public static final String JACC_CONTEXT_ID = "hibernate.jacc.ctx.id";
@@ -111,16 +117,19 @@
 	 */
 	public EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map overridenProperties) {
 		Ejb3Configuration cfg = new Ejb3Configuration();
-		return cfg.createEntityManagerFactory( persistenceUnitName, overridenProperties );
+		cfg.configure( persistenceUnitName, overridenProperties );
+		return cfg.buildEntityManagerFactory();
 	}
 
 	public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map map) {
 		Ejb3Configuration cfg = new Ejb3Configuration();
-		return cfg.createContainerEntityManagerFactory( info, map );
+		cfg.configure( info, map );
+		return cfg.buildEntityManagerFactory();
 	}
 
 	/**
 	 * create a factory from a canonical version
+	 * @deprecated
 	 */
 	// This is used directly by JBoss so don't remove until further notice.  bill at jboss.org
 	public EntityManagerFactory createEntityManagerFactory(Map properties) {

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/QueryImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/QueryImpl.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/QueryImpl.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -7,6 +7,7 @@
 import java.util.List;
 import javax.persistence.FlushModeType;
 import javax.persistence.NoResultException;
+import javax.persistence.NonUniqueResultException;
 import javax.persistence.Query;
 import javax.persistence.TemporalType;
 import static javax.persistence.TemporalType.*;
@@ -16,7 +17,6 @@
 import org.hibernate.FlushMode;
 import org.hibernate.HibernateException;
 import org.hibernate.QueryParameterException;
-import org.hibernate.SQLQuery;
 import org.hibernate.TypeMismatchException;
 import org.hibernate.ejb.util.ConfigurationHelper;
 import org.hibernate.hql.QueryExecutionRequestException;
@@ -28,6 +28,7 @@
 public class QueryImpl implements Query, HibernateQuery {
 	private org.hibernate.Query query;
 	private HibernateEntityManagerImplementor em;
+	private Boolean isPositional = null;
 
 	public QueryImpl(org.hibernate.Query query, AbstractEntityManagerImpl em) {
 		this.query = query;
@@ -76,13 +77,17 @@
 
 	public Object getSingleResult() {
 		try {
-			Object result = query.uniqueResult();
-
-			if ( result == null ) {
+			List result = query.list();
+			if ( result.size() == 0 ) {
 				em.throwPersistenceException( new NoResultException( "No entity found for query" ) );
 			}
-
-			return result;
+			else if ( result.size() > 1 ) {
+				em.throwPersistenceException( new NonUniqueResultException( "result returns " + result.size() + " elements") );
+			}
+			else {
+				return result.get(0);
+			}
+			return null; //should never happen
 		}
 		catch (QueryExecutionRequestException he) {
 			throw new IllegalStateException(he);
@@ -113,7 +118,7 @@
 			throw new IllegalArgumentException(
 					"Negative ("
 							+ firstResult
-							+ ") parameter passed in to setMaxResults"
+							+ ") parameter passed in to setFirstResult"
 			);
 		}
 		query.setFirstResult( firstResult );
@@ -222,7 +227,7 @@
 
 	public Query setParameter(int position, Object value) {
 		try {
-			if ( isEJBQLQuery() ) {
+			if ( isPositionalParameter() ) {
 				this.setParameter( Integer.toString( position ), value );
 			}
 			else {
@@ -239,13 +244,30 @@
 		}
 	}
 
-	private boolean isEJBQLQuery() {
-		return ! ( query instanceof SQLQuery );
+	private boolean isPositionalParameter() {
+		if (isPositional == null) {
+			//compute it
+			String queryString = query.getQueryString();
+			int index = queryString.indexOf( '?' );
+			//there is a ? and the following char is a digit
+			if (index == -1) {
+				//no ?
+				isPositional = true;
+			}
+			else if ( index == queryString.length() - 1 ) {
+				// "... ?"
+				isPositional = false;
+			}
+			else {
+				isPositional = Character.isDigit( queryString.charAt( index + 1 ) );
+			}
+		}
+		return isPositional;
 	}
 
 	public Query setParameter(int position, Date value, TemporalType temporalType) {
 		try {
-			if ( isEJBQLQuery() ) {
+			if ( isPositionalParameter() ) {
 				String name = Integer.toString( position );
 				this.setParameter( name, value, temporalType );
 			}
@@ -273,7 +295,7 @@
 
 	public Query setParameter(int position, Calendar value, TemporalType temporalType) {
 		try {
-			if ( isEJBQLQuery() ) {
+			if ( isPositionalParameter() ) {
 				String name = Integer.toString( position );
 				this.setParameter( name, value, temporalType );
 			}

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/TransactionImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/TransactionImpl.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/TransactionImpl.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -82,7 +82,7 @@
 		finally {
 			try {
 				if (entityManager !=  null) {
-					Session session = ( (HibernateEntityManager) entityManager ).getSession();
+					Session session = getSession();
 					if ( session != null && session.isOpen() ) session.clear();
 				}
 			}

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/Version.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/Version.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/Version.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -8,7 +8,7 @@
  * @author Emmanuel Bernard
  */
 public class Version {
-	public static String VERSION = "3.2.0.CR1";
+	public static final String VERSION = "3.2.0.CR3";
 	private static Log log = LogFactory.getLog( Version.class );
 
 	static {

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/connection/InjectedDataSourceConnectionProvider.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/connection/InjectedDataSourceConnectionProvider.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/connection/InjectedDataSourceConnectionProvider.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,6 +2,8 @@
 package org.hibernate.ejb.connection;
 
 import java.util.Properties;
+import java.sql.Connection;
+import java.sql.SQLException;
 import javax.sql.DataSource;
 
 import org.apache.commons.logging.Log;
@@ -18,6 +20,7 @@
  * @see org.hibernate.connection.ConnectionProvider
  */
 public class InjectedDataSourceConnectionProvider extends DatasourceConnectionProvider {
+	//TODO make datasource connection provider properties protected in 3.3
 	private String user;
 	private String pass;
 
@@ -35,4 +38,13 @@
 		log.info( "Using provided datasource" );
 	}
 
+	@Override
+	public Connection getConnection() throws SQLException {
+		if (user != null || pass != null) {
+			return getDataSource().getConnection(user, pass);
+		}
+		else {
+			return getDataSource().getConnection();
+		}
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/BeanCallback.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/BeanCallback.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/BeanCallback.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -25,7 +25,7 @@
 		catch (InvocationTargetException e) {
 			//keep runtime exceptions as is
 			if ( e.getTargetException() instanceof RuntimeException ) {
-				throw (RuntimeException) e.getCause();
+				throw (RuntimeException) e.getTargetException();
 			}
 			else {
 				throw new RuntimeException( e.getTargetException() );

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/CallbackResolver.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/CallbackResolver.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/CallbackResolver.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -14,16 +14,14 @@
 import java.util.List;
 import javax.persistence.Entity;
 import javax.persistence.EntityListeners;
+import javax.persistence.ExcludeDefaultListeners;
 import javax.persistence.ExcludeSuperclassListeners;
 import javax.persistence.MappedSuperclass;
 import javax.persistence.PersistenceException;
-import javax.persistence.ExcludeDefaultListeners;
 
+import org.hibernate.reflection.ReflectionManager;
 import org.hibernate.reflection.XClass;
 import org.hibernate.reflection.XMethod;
-import org.hibernate.reflection.ReflectionManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
@@ -32,7 +30,7 @@
 public final class CallbackResolver {
 	private static boolean useAnnotationAnnotatedByListener;
 
-	{
+	static {
 		//check whether reading annotations of annotations is useful or not
 		useAnnotationAnnotatedByListener = false;
 		Target target = (Target) EntityListeners.class.getAnnotation( Target.class );
@@ -42,7 +40,6 @@
 			}
 		}
 	}
-	private static Log log = LogFactory.getLog( CallbackResolver.class );
 
 	private CallbackResolver() {
 	}
@@ -107,13 +104,13 @@
 		while ( currentClazz != null );
 
 		//handle default listeners
-		if (! stopDefaultListeners) {
+		if ( ! stopDefaultListeners ) {
 			List<Class> defaultListeners = (List<Class>) reflectionManager.getDefaults().get( EntityListeners.class );
 
-			if (defaultListeners != null) {
+			if ( defaultListeners != null ) {
 				int defaultListenerSize = defaultListeners.size();
-				for (int i = defaultListenerSize - 1 ; i >= 0 ; i--) {
-					orderedListeners.add( defaultListeners.get(i) );
+				for ( int i = defaultListenerSize - 1; i >= 0 ; i-- ) {
+					orderedListeners.add( defaultListeners.get( i ) );
 				}
 			}
 		}
@@ -127,13 +124,13 @@
 					List<XMethod> methods = xListener.getDeclaredMethods();
 					final int size = methods.size();
 					for ( int i = 0; i < size ; i++ ) {
-						final XMethod xMethod = methods.get(i);
+						final XMethod xMethod = methods.get( i );
 						if ( xMethod.isAnnotationPresent( annotation ) ) {
 							final Method method = reflectionManager.toMethod( xMethod );
 							final String methodName = method.getName();
 							if ( ! callbacksMethodNames.contains( methodName ) ) {
 								//overriden method, remove the superclass overriden method
-								if (  callback == null ) {
+								if ( callback == null ) {
 									try {
 										callback = new ListenerCallback( method, listener.newInstance() );
 									}
@@ -174,7 +171,7 @@
 					}
 					xListener = null;  //xListener.getSuperclass();
 				}
-				while (xListener != null);
+				while ( xListener != null );
 			}
 		}
 		return callbacks.toArray( new Callback[ callbacks.size() ] );

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/ListenerCallback.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/ListenerCallback.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/event/ListenerCallback.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -33,7 +33,7 @@
 		catch (InvocationTargetException e) {
 			//keep runtime exceptions as is
 			if ( e.getTargetException() instanceof RuntimeException ) {
-				throw (RuntimeException) e.getCause();
+				throw (RuntimeException) e.getTargetException();
 			}
 			else {
 				throw new RuntimeException( e.getTargetException() );

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/instrument/InterceptFieldClassFileTransformer.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/instrument/InterceptFieldClassFileTransformer.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/instrument/InterceptFieldClassFileTransformer.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -3,10 +3,11 @@
 
 import java.lang.instrument.IllegalClassFormatException;
 import java.security.ProtectionDomain;
+import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.hibernate.bytecode.util.ClassFilter;
+import org.hibernate.bytecode.util.FieldFilter;
 import org.hibernate.cfg.Environment;
 
 /**
@@ -16,12 +17,34 @@
  * @author Emmanuel Bernard
  */
 public class InterceptFieldClassFileTransformer implements javax.persistence.spi.ClassTransformer {
-	Log log = LogFactory.getLog( InterceptFieldClassFileTransformer.class.getName() );
 	private org.hibernate.bytecode.ClassTransformer classTransformer;
 
 	public InterceptFieldClassFileTransformer(List<String> entities) {
-		classTransformer = Environment.getBytecodeProvider().getEntityClassTransformer(
-				null, entities.toArray( new String[ entities.size() ] )
+//		classTransformer = Environment.getBytecodeProvider().getEntityClassTransformer(
+//				null, entities.toArray( new String[ entities.size() ] )
+//		);
+		final List<String> copyEntities = new ArrayList<String>( entities.size() );
+		copyEntities.addAll( entities );
+		classTransformer = Environment.getBytecodeProvider().getTransformer(
+				//TODO change it to a static class to make it faster?
+				new ClassFilter() {
+					public boolean shouldInstrumentClass(String className) {
+						return copyEntities.contains( className );
+					}
+				},
+				//TODO change it to a static class to make it faster?
+				new FieldFilter() {
+
+					public boolean shouldInstrumentField(String className, String fieldName) {
+						return true;
+					}
+
+					public boolean shouldTransformFieldAccess(
+							String transformingClassName, String fieldOwnerClassName, String fieldName
+					) {
+						return true;
+					}
+				}
 		);
 	}
 

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -28,7 +28,7 @@
 	protected void doProcessElements() throws IOException {
 		File jarFile;
 		try {
-			jarFile = new File( jarUrl.toURI().getPath() );
+			jarFile = new File( jarUrl.toURI().getSchemeSpecificPart() );
 		}
 		catch (URISyntaxException e) {
 			log.warn( "Malformed url: " + jarUrl, e );

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/FileZippedJarVisitor.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/FileZippedJarVisitor.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/FileZippedJarVisitor.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -20,18 +20,18 @@
 public class FileZippedJarVisitor extends JarVisitor {
 	private static Log log = LogFactory.getLog( FileZippedJarVisitor.class );
 
-	protected FileZippedJarVisitor(String fileName, Filter[] filters) {
+	public FileZippedJarVisitor(String fileName, Filter[] filters) {
 		super( fileName, filters );
 	}
 
-	protected FileZippedJarVisitor(URL url, Filter[] filters) {
+	public FileZippedJarVisitor(URL url, Filter[] filters) {
 		super( url, filters );
 	}
 
 	protected void doProcessElements() throws IOException {
 		JarFile jarFile;
 		try {
-			jarFile = new JarFile( jarUrl.toURI().getPath() );
+			jarFile = new JarFile( jarUrl.toURI().getSchemeSpecificPart() );
 		}
 		catch (IOException ze) {
 			log.warn( "Unable to find file (ignored): " + jarUrl, ze );

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/JarVisitor.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/JarVisitor.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/JarVisitor.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -57,6 +57,11 @@
 					|| "wsjar".equals( protocol ) ) { //Websphere has it's own way
 				jarUrl = new URL( file );
 			}
+			else if ("code-source".equals( url.getProtocol() ) ) {
+				//OC4J prevent ejb.jar access (ie everything without path
+				//fix contributed by the community
+				jarUrl = new File(file).toURL();
+			}
 			else {
 				jarUrl = new URL( protocol, url.getHost(), url.getPort(), file );
 			}
@@ -208,8 +213,8 @@
 		if ( !done ) {
 			//avoid url access and so on
 			if ( filters.size() > 0 ) doProcessElements();
+			done = true;
 		}
-		done = true;
 		return entries;
 	}
 
@@ -229,8 +234,10 @@
 		}
 		else {
 			String name = entryName;
+			boolean accepted = false;
 			for ( FileFilter filter : fileFilters ) {
 				if ( filter.accept( name ) ) {
+					accepted = true;
 					InputStream localIs;
 					if ( filter.getStream() ) {
 						localIs = secondIs;
@@ -246,24 +253,33 @@
 					this.entries[index].add( entry );
 				}
 			}
+			if (!accepted) {
+				//not accepted free resources
+				is.close();
+				secondIs.close();
+			}
 		}
 	}
 
 	private void executeJavaElementFilter(
 			String name, Set<JavaElementFilter> filters, InputStream is, InputStream secondIs
 	) throws IOException {
+		boolean accepted = false;
 		for ( JavaElementFilter filter : filters ) {
 			if ( filter.accept( name ) ) {
-				InputStream localIs;
-				if ( filter.getStream() ) {
-					localIs = secondIs;
-				}
-				else {
-					localIs = null;
-					secondIs.close();
-				}
+				//FIXME cannot currently have a class filtered twice but matching once
+				// need to copy the is
 				boolean match = checkAnnotationMatching( is, filter );
 				if ( match ) {
+					accepted = true;
+					InputStream localIs;
+					if ( filter.getStream() ) {
+						localIs = secondIs;
+					}
+					else {
+						localIs = null;
+						secondIs.close();
+					}
 					log.debug( "Java element filter matched for " + name );
 					Entry entry = new Entry( name, localIs );
 					int index = this.filters.indexOf( filter );
@@ -272,6 +288,10 @@
 				}
 			}
 		}
+		if (!accepted) {
+			is.close();
+			secondIs.close();
+		}
 	}
 
 	private boolean checkAnnotationMatching(InputStream is, JavaElementFilter filter) throws IOException {

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -6,6 +6,7 @@
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
+import java.util.Map;
 import javax.persistence.spi.PersistenceUnitTransactionType;
 
 /**
@@ -127,4 +128,55 @@
 	public void setExcludeUnlistedClasses(boolean excludeUnlistedClasses) {
 		this.excludeUnlistedClasses = excludeUnlistedClasses;
 	}
+
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append( "PersistenceMetadata [\n")
+				.append("\tname: ").append(name).append("\n")
+				.append("\tjtaDataSource: ").append(jtaDatasource).append("\n")
+				.append("\tnonJtaDataSource: ").append(nonJtaDatasource).append("\n")
+				.append("\ttransactionType: ").append(transactionType).append("\n")
+				.append("\tprovider: ").append(provider).append("\n")
+				.append("\tclasses[\n");
+		if (classes != null) {
+			for (String elt : classes) {
+				sb.append("\t\t").append( elt );
+			}
+		}
+		sb.append( "\t]\n")
+				.append("\tpackages[\n");
+		if (packages != null) {
+			for (String elt : packages) {
+				sb.append("\t\t").append( elt ).append("\n");
+			}
+		}
+		sb.append( "\t]\n")
+				.append("\tmappingFiles[\n");
+		if (mappingFiles != null) {
+			for (String elt : mappingFiles) {
+				sb.append("\t\t").append( elt ).append("\n");
+			}
+		}
+		sb.append( "\t]\n")
+				.append("\tjarFiles[\n");
+		if (jarFiles != null) {
+			for (String elt : jarFiles) {
+				sb.append("\t\t").append( elt ).append("\n");
+			}
+		}
+		sb.append( "\t]\n")
+				.append("\thbmfiles: ")
+				.append( hbmfiles != null ? hbmfiles.size() : 0 ).append("\n")
+				.append("\tproperties[\n");
+
+		if (props != null) {
+			for ( Map.Entry elt : props.entrySet()) {
+				sb.append("\t\t").append( elt.getKey() ).append(": ").append( elt.getValue() ).append("\n");
+			}
+		}
+		sb.append( "\t]").append( "]");
+
+		return sb.toString();
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/XmlHelper.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/XmlHelper.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/XmlHelper.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -144,17 +144,17 @@
 		}
 
 		NodeList children = element.getChildNodes();
-		String result = "";
+		StringBuilder result = new StringBuilder("");
 		for ( int i = 0; i < children.getLength() ; i++ ) {
 			if ( children.item( i ).getNodeType() == Node.TEXT_NODE ||
 					children.item( i ).getNodeType() == Node.CDATA_SECTION_NODE ) {
-				result += children.item( i ).getNodeValue();
+				result.append( children.item( i ).getNodeValue() );
 			}
-			else if ( children.item( i ).getNodeType() == Node.COMMENT_NODE ) {
-				// Ignore comment nodes
-			}
+//			else if ( children.item( i ).getNodeType() == Node.COMMENT_NODE ) {
+//				// Ignore comment nodes
+//			}
 		}
-		return result.trim();
+		return result.toString().trim();
 	}
 
 	/**

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/java/org/hibernate/ejb/util/NamingHelper.java (from rev 10565, trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/util/NamingHelper.java)

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/NoPackageEntity.java (from rev 10565, trunk/HibernateExt/ejb/src/test/NoPackageEntity.java)

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/QueryTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/QueryTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/QueryTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,8 +2,8 @@
 package org.hibernate.ejb.test;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
-import java.util.Date;
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
 import javax.persistence.TemporalType;
@@ -44,7 +44,7 @@
 		em.persist( item );
 		Query q = em.createQuery( "select count(i) from Item i where i.name like :itemName" );
 		q.setParameter( "itemName", "%" );
-		assertTrue( q.getSingleResult() instanceof Long);
+		assertTrue( q.getSingleResult() instanceof Long );
 		em.getTransaction().rollback();
 		em.close();
 	}
@@ -194,8 +194,10 @@
 		em.persist( w );
 		em.getTransaction().commit();
 		em.getTransaction().begin();
-		Query query = em.createQuery( "select w from " + Wallet.class.getName() + " w where w.brand = ?1" );
-		query.setParameter( 1, "Lacoste" );
+		Query query = em.createQuery( "select w from " + Wallet.class.getName() + " w where w.brand in (?1)" );
+		List brands = new ArrayList();
+		brands.add( "Lacoste" );
+		query.setParameter( 1, brands );
 		w = (Wallet) query.getSingleResult();
 		assertNotNull( w );
 		query = em.createQuery( "select w from " + Wallet.class.getName() + " w where w.marketEntrance = ?1" );
@@ -207,7 +209,7 @@
 		em.close();
 	}
 
-	public void testNativePositionalParameter() throws Exception {
+	public void testNativeQuestionMarkParameter() throws Exception {
 		EntityManager em = factory.createEntityManager();
 		em.getTransaction().begin();
 		Wallet w = new Wallet();
@@ -226,6 +228,34 @@
 		em.close();
 	}
 
+	public void testNativeQueryWithPositionalParameter() {
+
+		Item item = new Item( "Mouse", "Micro$oft mouse" );
+
+		EntityManager em = factory.createEntityManager();
+		em.getTransaction().begin();
+		em.persist( item );
+		assertTrue( em.contains( item ) );
+		em.getTransaction().commit();
+
+		em.getTransaction().begin();
+		Query query = em.createNativeQuery( "select * from Item where name = ?1", Item.class );
+		query.setParameter( 1, "Mouse" );
+		item = (Item) query.getSingleResult();
+		assertNotNull( item );
+		assertEquals( "Micro$oft mouse", item.getDescr() );
+		query = em.createNativeQuery( "select * from Item where name = ?", Item.class );
+		query.setParameter( 1, "Mouse" );
+		item = (Item) query.getSingleResult();
+		assertNotNull( item );
+		assertEquals( "Micro$oft mouse", item.getDescr() );
+		em.remove( item );
+		em.getTransaction().commit();
+
+		em.close();
+
+	}
+
 	public void testDistinct() throws Exception {
 		EntityManager em = factory.createEntityManager();
 		em.getTransaction().begin();
@@ -299,7 +329,11 @@
 		em.flush();
 		em.clear();
 
-		assertEquals( 1, em.createNativeQuery( "update Item i set i.descr = 'Logitech Mouse' where i.name = 'Mouse'").executeUpdate() );
+		assertEquals(
+				1, em.createNativeQuery(
+				"update Item i set i.descr = 'Logitech Mouse' where i.name = 'Mouse'"
+		).executeUpdate()
+		);
 		item = em.find( Item.class, item.getName() );
 		assertEquals( "Logitech Mouse", item.getDescr() );
 		em.remove( item );

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association)

Deleted: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/AssociationTest.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/AssociationTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/AssociationTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,59 +0,0 @@
-//$Id: $
-package org.hibernate.ejb.test.association;
-
-import javax.persistence.EntityManager;
-
-import org.hibernate.ejb.test.TestCase;
-
-/**
- * @author Emmanuel Bernard
- */
-public class AssociationTest extends TestCase {
-	public void testBidirOneToOne() throws Exception {
-		EntityManager em = factory.createEntityManager();
-		em.getTransaction().begin();
-		String id = "10";
-		Incident i = em.find( Incident.class, id );
-		if ( i == null ) {
-			i = new Incident( id );
-			IncidentStatus ist = new IncidentStatus( id );
-			i.setIncidentStatus( ist );
-			ist.setIncident( i );
-			em.persist( i );
-		}
-		em.getTransaction().commit();
-		em.clear();
-		em.getTransaction().begin();
-		em.remove( em.find(Incident.class, id) );
-		em.getTransaction().commit();
-		em.close();
-	}
-
-	public void testMergeAndBidirOneToOne() throws Exception {
-		EntityManager em = factory.createEntityManager();
-		em.getTransaction().begin();
-		Oven oven = new Oven();
-		Kitchen kitchen = new Kitchen();
-		em.persist( oven );
-		em.persist( kitchen );
-		kitchen.setOven( oven );
-		oven.setKitchen( kitchen );
-		em.flush();
-		em.clear();
-		//oven = em.find(Oven.class, oven.getId() );
-		oven = em.merge( oven );
-		em.flush();
-
-		em.getTransaction().rollback();
-		em.close();
-	}
-
-	public Class[] getAnnotatedClasses() {
-		return new Class[]{
-				Incident.class,
-				IncidentStatus.class,
-				Kitchen.class,
-				Oven.class
-		};
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/AssociationTest.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/AssociationTest.java)

Deleted: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Incident.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Incident.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Incident.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,39 +0,0 @@
-//$Id: $
-package org.hibernate.ejb.test.association;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.OneToOne;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
-public class Incident {
-	@Id
-	String id;
-
-	@OneToOne(cascade = CascadeType.ALL)
-	IncidentStatus incidentStatus;
-
-	public Incident() {
-	}
-
-	public Incident(String id) {
-		this.id = id;
-	}
-
-	public IncidentStatus getIncidentStatus() {
-		return incidentStatus;
-	}
-
-	public void setIncidentStatus(IncidentStatus incidentStatus) {
-		this.incidentStatus = incidentStatus;
-	}
-
-	@Override
-	public String toString() {
-		return "Incident: " + id + " " + incidentStatus;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Incident.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Incident.java)

Deleted: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/IncidentStatus.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/IncidentStatus.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/IncidentStatus.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,38 +0,0 @@
-//$Id: $
-package org.hibernate.ejb.test.association;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.OneToOne;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
-public class IncidentStatus {
-	@Id
-	String id;
-
-	@OneToOne(mappedBy = "incidentStatus")
-	Incident incident;
-
-	public IncidentStatus() {
-	}
-
-	public IncidentStatus(String id) {
-		this.id = id;
-	}
-
-	public Incident getIncident() {
-		return incident;
-	}
-
-	public void setIncident(Incident incident) {
-		this.incident = incident;
-	}
-
-	@Override
-	public String toString() {
-		return "IncidentStatus " + id;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/IncidentStatus.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/IncidentStatus.java)

Deleted: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Kitchen.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Kitchen.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Kitchen.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,35 +0,0 @@
-//$Id: $
-package org.hibernate.ejb.test.association;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToOne;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
-public class Kitchen {
-	@Id @GeneratedValue
-	private Long id;
-
-	@OneToOne(mappedBy = "kitchen")
-	private Oven oven;
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public Oven getOven() {
-		return oven;
-	}
-
-	public void setOven(Oven oven) {
-		this.oven = oven;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Kitchen.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Kitchen.java)

Deleted: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Oven.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Oven.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Oven.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,38 +0,0 @@
-//$Id: $
-package org.hibernate.ejb.test.association;
-
-import javax.persistence.Entity;
-import javax.persistence.OneToOne;
-import javax.persistence.JoinColumn;
-import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
-import javax.persistence.FetchType;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
-public class Oven {
-	@Id @GeneratedValue
-	private Long id;
-
-	@OneToOne(fetch= FetchType.LAZY)
-	@JoinColumn
-	private Kitchen kitchen;
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public Kitchen getKitchen() {
-		return kitchen;
-	}
-
-	public void setKitchen(Kitchen kitchen) {
-		this.kitchen = kitchen;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Oven.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/association/Oven.java)

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Author.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Author.java)

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/CascadeTest.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/CascadeTest.java)

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/FetchTest2.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/FetchTest2.java)

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Soldier2.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Soldier2.java)

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Song.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Song.java)

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Student.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Student.java)

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Teacher.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Teacher.java)

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Troop2.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Troop2.java)

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/GetReferenceTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/GetReferenceTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/GetReferenceTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -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
 		};
 	}
 }

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Mail.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Mail.java)

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/MergeTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/MergeTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/MergeTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -54,6 +54,38 @@
 		em.close();
 	}
 
+	public void testConcurrentMerge() {
+		Race race = new Race();
+		race.name = "Derby";
+		EntityManager em = factory.createEntityManager();
+		em.getTransaction().begin();
+		em.persist( race );
+		em.flush();
+		em.getTransaction().commit();
+		em.close();
+
+		race.name = "Magnicourt";
+
+		em = factory.createEntityManager();
+		em.getTransaction().begin();
+		Race race2 = em.find(Race.class, race.id );
+		race2.name = "Mans";
+
+		race = em.merge( race );
+		em.flush();
+		em.getTransaction().commit();
+		em.close();
+
+		em = factory.createEntityManager();
+		em.getTransaction().begin();
+		race2 = em.find(Race.class, race.id );
+		assertEquals( "Last commit win in merge", "Magnicourt", race2.name );
+
+		em.remove( race2 );
+		em.getTransaction().commit();
+		em.close();
+	}
+
 	public Class[] getAnnotatedClasses() {
 		return new Class[] {
 				Race.class,

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Race.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Race.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Race.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -21,4 +21,5 @@
 	@IndexColumn( name="index" ) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
 	@org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) 
 	public List<Competitor> competitors = new ArrayList<Competitor>();
+	public String name;
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/RemoveTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/RemoveTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/RemoveTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -9,7 +9,7 @@
  * @author Emmanuel Bernard
  */
 public class RemoveTest extends TestCase {
-	public void testMergeWithIndexColumn() {
+	public void testRemove() {
 		Race race = new Race();
 		race.competitors.add( new Competitor() );
 		race.competitors.add( new Competitor() );
@@ -24,6 +24,17 @@
 		em.close();
 	}
 
+	public void testRemoveAndFind() {
+		Race race = new Race();
+		EntityManager em = factory.createEntityManager();
+		em.getTransaction().begin();
+		em.persist( race );
+		em.remove( race );
+		assertNull( em.find( Race.class, race.id ) );
+		em.getTransaction().rollback();
+		em.close();
+	}
+
 	public Class[] getAnnotatedClasses() {
 		return new Class[] {
 				Race.class,

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/exception/ExceptionTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/exception/ExceptionTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/exception/ExceptionTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,10 +1,12 @@
 //$Id: $
 package org.hibernate.ejb.test.exception;
 
+import java.util.Map;
 import javax.persistence.EntityManager;
+import javax.persistence.EntityNotFoundException;
 import javax.persistence.OptimisticLockException;
-import javax.persistence.EntityNotFoundException;
 
+import org.hibernate.cfg.Environment;
 import org.hibernate.ejb.test.TestCase;
 
 /**
@@ -30,11 +32,13 @@
 		em.getTransaction().begin();
 		music.setName( "Rock" );
 		try {
+
 			em.flush();
 			fail("Should raise an optimistic lock exception");
 		}
 		catch( OptimisticLockException e) {
 			//success
+			assertEquals( music, e.getEntity() );
 		}
 		catch( Exception e ) {
 			fail("Should raise an optimistic lock exception");
@@ -60,6 +64,13 @@
 		}
 	}
 
+	@Override
+	public Map getConfig() {
+		Map config = super.getConfig();
+		config.put( Environment.BATCH_VERSIONED_DATA, "false");
+		return config;
+	}
+
 	public Class[] getAnnotatedClasses() {
 		return new Class[] {
 				Music.class

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/exception/Music.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/exception/Music.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/exception/Music.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,6 +1,7 @@
 //$Id: $
 package org.hibernate.ejb.test.exception;
 
+import java.io.Serializable;
 import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.GeneratedValue;
@@ -10,7 +11,7 @@
  * @author Emmanuel Bernard
  */
 @Entity
-public class Music {
+public class Music implements Serializable {
 	private Integer id;
 	private Integer version;
 	private String name;

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance)

Deleted: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Fruit.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Fruit.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Fruit.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,27 +0,0 @@
-//$Id: $
-package org.hibernate.ejb.test.inheritance;
-
-import javax.persistence.Entity;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
- at Inheritance(strategy = InheritanceType.JOINED)
-public abstract class Fruit {
-	Long id;
-
-	@Id
-	@GeneratedValue
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Fruit.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Fruit.java)

Deleted: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/InheritanceTest.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/InheritanceTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/InheritanceTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,41 +0,0 @@
-//$Id: $
-package org.hibernate.ejb.test.inheritance;
-
-import javax.persistence.EntityManager;
-
-import org.hibernate.ejb.test.TestCase;
-
-/**
- * @author Emmanuel Bernard
- */
-public class InheritanceTest extends TestCase {
-
-	public void testFind() throws Exception {
-		EntityManager firstSession = factory.createEntityManager( );
-        Strawberry u = new Strawberry();
-		u.setSize( 12l );
-		firstSession.getTransaction().begin();
-        firstSession.persist(u);
-        firstSession.getTransaction().commit();
-        Long newId = u.getId();
-        firstSession.clear();
-
-		firstSession.getTransaction().begin();
-        // 1.
-        Strawberry result1 = firstSession.find(Strawberry.class, newId);
-        assertNotNull( result1 );
-
-        // 2.
-        Strawberry result2 = (Strawberry) firstSession.find(Fruit.class, newId);
-        System.out.println("2. result is:" + result2);
-
-        firstSession.getTransaction().commit();
-        firstSession.close();
-	}
-	public Class[] getAnnotatedClasses() {
-		return new Class[] {
-				Fruit.class,
-				Strawberry.class
-		};
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/InheritanceTest.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/InheritanceTest.java)

Deleted: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Strawberry.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Strawberry.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Strawberry.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,20 +0,0 @@
-//$Id: $
-package org.hibernate.ejb.test.inheritance;
-
-import javax.persistence.Entity;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
-public class Strawberry extends Fruit {
-	private Long size;
-
-	public Long getSize() {
-		return size;
-	}
-
-	public void setSize(Long size) {
-		this.size = size;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Strawberry.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/inheritance/Strawberry.java)

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explicitpar (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explicitpar)

Deleted: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explicitpar/Washer.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explicitpar/Washer.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explicitpar/Washer.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,12 +0,0 @@
-//$Id: $
-package org.hibernate.ejb.test.pack.explicitpar;
-
-import javax.persistence.Entity;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
-public class Washer {
-	//No @id so picking it up should fail
-}

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explicitpar/Washer.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explicitpar/Washer.java)

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/packaging/JarVisitorTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/packaging/JarVisitorTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/packaging/JarVisitorTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -14,6 +14,7 @@
 import org.hibernate.ejb.packaging.ExplodedJarVisitor;
 import org.hibernate.ejb.packaging.InputStreamZippedJarVisitor;
 import org.hibernate.ejb.packaging.JarVisitor;
+import org.hibernate.ejb.packaging.FileZippedJarVisitor;
 import org.hibernate.ejb.test.pack.defaultpar.ApplicationServer;
 import org.hibernate.ejb.test.pack.explodedpar.Carpet;
 
@@ -43,7 +44,7 @@
 		assertEquals( 0, visitor.getMatchingEntries()[2].size() );
 	}
 
-	public void testZippedJar() throws Exception {
+	public void testInputStreamZippedJar() throws Exception {
 		String jarFileName = "file:./build/testresources/defaultpar.par";
 		//JarVisitor jarVisitor = new ZippedJarVisitor( jarFileName, true, true );
 		JarVisitor.Filter[] filters = getFilters();
@@ -57,6 +58,10 @@
 		assertTrue( entries.contains( entry ) );
 		assertNull( ( (JarVisitor.Entry) entries.iterator().next() ).getInputStream() );
 		assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
+		for (JarVisitor.Entry localEntry : (Set<JarVisitor.Entry>) jarVisitor.getMatchingEntries()[2] ) {
+			assertNotNull( localEntry.getInputStream() );
+			localEntry.getInputStream().close();
+		}
 
 //		Set<String> classes = jarVisitor.getClassNames();
 //		assertEquals( 3, classes.size() );
@@ -65,6 +70,31 @@
 //		assertTrue( classes.contains( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName() ) );
 	}
 
+	public void testZippedJar() throws Exception {
+		String jarFileName = "file:./build/testresources/defaultpar.par";
+		//JarVisitor jarVisitor = new ZippedJarVisitor( jarFileName, true, true );
+		JarVisitor.Filter[] filters = getFilters();
+		JarVisitor jarVisitor = new FileZippedJarVisitor( new URL( jarFileName ), filters );
+		assertEquals( "defaultpar", jarVisitor.getUnqualifiedJarName() );
+		Set entries = jarVisitor.getMatchingEntries()[1];
+		assertEquals( 3, entries.size() );
+		JarVisitor.Entry entry = new JarVisitor.Entry( ApplicationServer.class.getName(), null );
+		assertTrue( entries.contains( entry ) );
+		entry = new JarVisitor.Entry( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName(), null );
+		assertTrue( entries.contains( entry ) );
+		assertNull( ( (JarVisitor.Entry) entries.iterator().next() ).getInputStream() );
+		assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
+		for (JarVisitor.Entry localEntry : (Set<JarVisitor.Entry>) jarVisitor.getMatchingEntries()[2] ) {
+			assertNotNull( localEntry.getInputStream() );
+			localEntry.getInputStream().close();
+		}
+//		Set<String> classes = jarVisitor.getClassNames();
+//		assertEquals( 3, classes.size() );
+//		assertTrue( classes.contains( ApplicationServer.class.getName() ) );
+//		assertTrue( classes.contains( Mouse.class.getName() ) );
+//		assertTrue( classes.contains( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName() ) );
+	}
+
 	public void testExplodedJar() throws Exception {
 		String jarFileName = "./build/testresources/explodedpar.par";
 		//JarVisitor jarVisitor = new ExplodedJarVisitor( jarFileName, true, true );
@@ -78,7 +108,10 @@
 
 		JarVisitor.Entry entry = new JarVisitor.Entry( Carpet.class.getName(), null );
 		assertTrue( entries[1].contains( entry ) );
-
+		for (JarVisitor.Entry localEntry : (Set<JarVisitor.Entry>) jarVisitor.getMatchingEntries()[2] ) {
+			assertNotNull( localEntry.getInputStream() );
+			localEntry.getInputStream().close();
+		}
 //		Set<String> classes = jarVisitor.getClassNames();
 //		assertEquals( 2, classes.size() );
 //		assertEquals( 1, jarVisitor.getPackageNames().size() );
@@ -86,7 +119,7 @@
 //		assertTrue( classes.contains( Carpet.class.getName() ) );
 	}
 
-	public void testDuplicateFilterExplodedJar() throws Exception {
+	public void testDuplicateFilterExplodedJarExpectedfail() throws Exception {
 		String jarFileName = "./build/testresources/explodedpar.par";
 		//JarVisitor jarVisitor = new ExplodedJarVisitor( jarFileName, true, true );
 		JarVisitor.Filter[] filters = getFilters();
@@ -99,7 +132,7 @@
 		for ( JarVisitor.Filter filter : filters ) {
 			dupeFilters[index++] = filter;
 		}
-		JarVisitor jarVisitor = new ExplodedJarVisitor( jarFileName, filters );
+		JarVisitor jarVisitor = new ExplodedJarVisitor( jarFileName, dupeFilters );
 		assertEquals( "explodedpar", jarVisitor.getUnqualifiedJarName() );
 		Set[] entries = jarVisitor.getMatchingEntries();
 		assertEquals( 1, entries[1].size() );

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/Book.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/Book.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/Book.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -5,6 +5,7 @@
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
+import javax.persistence.Version;
 
 /**
  * @author Emmanuel Bernard
@@ -16,6 +17,9 @@
 	public Integer id;
 	public String name;
 
+	@Version
+	public Integer version;
+
 	public Integer getId() {
 		return id;
 	}
@@ -31,4 +35,12 @@
 	public void setName(String name) {
 		this.name = name;
 	}
+
+	public Integer getVersion() {
+		return version;
+	}
+
+	public void setVersion(Integer version) {
+		this.version = version;
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,11 +1,12 @@
 //$Id$
 package org.hibernate.ejb.test.transaction;
 
+import java.util.List;
 import javax.persistence.EntityManager;
-import javax.persistence.EntityNotFoundException;
 import javax.persistence.LockModeType;
 import javax.persistence.RollbackException;
 import javax.persistence.TransactionRequiredException;
+import javax.persistence.PersistenceException;
 
 import org.hibernate.ejb.HibernateEntityManagerFactory;
 import org.hibernate.ejb.test.TestCase;
@@ -182,17 +183,43 @@
 		em.close();
 	}
 
+	public void testTransactionCommitDoesNotFlush() throws Exception {
+		EntityManager em = factory.createEntityManager();
+		em.getTransaction().begin();
+		Book book = new Book();
+		book.name = "Java for Dummies";
+		em.persist( book );
+		em.getTransaction().commit();
+		em.close();
+		em = factory.createEntityManager();
+		em.getTransaction().begin();
+		List result = em.createQuery("select book from Book book where book.name = :title").
+				setParameter( "title", book.name ).getResultList();
+		assertEquals( "EntityManager.commit() should trigger a flush()", 1, result.size() );
+		em.getTransaction().commit();
+		em.close();
+	}
+
 	public void testRollbackOnlyOnPersistenceException() throws Exception {
 		Book book = new Book();
 		book.name = "Stolen keys";
-		book.id = new Integer( 50 );
+		book.id = null; //new Integer( 50 );
 		EntityManager em = factory.createEntityManager();
 		em.getTransaction().begin();
 		try {
-			em.refresh( book );
-			fail( "Get reference on wrong entity should fail" );
+			em.persist( book );
+			em.flush();
+			em.clear();
+			book.setName( "kitty kid");
+			em.merge( book );
+			em.flush();
+			em.clear();
+			book.setName( "kitty kid2"); //non updated version
+			em.merge( book );
+			em.flush();
+			fail( "optimistic locking exception" );
 		}
-		catch (EntityNotFoundException e) {
+		catch (PersistenceException e) {
 			//success
 		}
 		try {

Copied: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/Article.java (from rev 10565, trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/Article.java)

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/XmlTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/XmlTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/XmlTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,30 +1,28 @@
 //$Id: $
 package org.hibernate.ejb.test.xml;
 
-import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityManager;
 
-import junit.framework.TestCase;
-import org.hibernate.ejb.HibernatePersistence;
-import org.hibernate.ejb.test.connection.FakeDataSourceException;
-import org.hibernate.ejb.test.connection.PersistenceUnitInfoImpl;
+import org.hibernate.ejb.test.TestCase;
 
 /**
  * @author Emmanuel Bernard
  */
 public class XmlTest extends TestCase {
-	public void testPersistenceInfo() throws Exception {
-		PersistenceUnitInfoImpl info = new PersistenceUnitInfoImpl(
-				new String[]{
-						"org/hibernate/ejb/test/xml/orm.xml",
-						"org/hibernate/ejb/test/xml/orm2.xml"
-				}
-		);
-		try {
-			EntityManagerFactory emf = ( new HibernatePersistence() ).createContainerEntityManagerFactory( info, null );
-			fail( "FakeDatasource should have been used" );
-		}
-		catch (FakeDataSourceException fde) {
-			//success
-		}
+	public void testXmlMappingCorrectness() throws Exception {
+		EntityManager em = factory.createEntityManager();
+		em.close();
 	}
+
+	public Class[] getAnnotatedClasses() {
+		return new Class[0];
+	}
+
+	@Override
+	public String[] getEjb3DD() {
+		return new String[] {
+				"org/hibernate/ejb/test/xml/orm.xml",
+				"org/hibernate/ejb/test/xml/orm2.xml"
+		};
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/orm.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/orm.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/orm.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -5,6 +5,14 @@
                  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
                  version="1.0"
         >
+    <persistence-unit-metadata>
+        <persistence-unit-defaults>
+            <schema>MY_SCHEMA</schema>
+            <catalog>MY_CATALOG</catalog>
+            <access>PROPERTY</access>
+            <cascade-persist/>
+        </persistence-unit-defaults>
+    </persistence-unit-metadata>
     <package>org.hibernate.ejb.test.xml</package>
     <entity class="Light" metadata-complete="true" access="FIELD">
         <attributes>
@@ -14,4 +22,12 @@
             <basic name="power"></basic>
         </attributes>
     </entity>
+    <entity class="Article"
+            metadata-complete="false">
+        <attributes>
+            <id name="id">
+                <generated-value strategy="SEQUENCE"/>
+            </id>
+        </attributes>
+    </entity>
 </entity-mappings>
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/orm2.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/orm2.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test/org/hibernate/ejb/test/xml/orm2.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -5,8 +5,7 @@
                  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
                  version="1.0"
         >
-    <package>org.hibernate.ejb.test.xml</package>
-    <entity class="Lighter" name="ALighter" access="FIELD" metadata-complete="true">
+    <entity class="org.hibernate.ejb.test.xml.Lighter" name="ALighter" access="FIELD" metadata-complete="true">
         <attributes>
             <id name="name">
                 <column name="fld_id"/>
@@ -14,4 +13,15 @@
             <basic name="power"></basic>
         </attributes>
     </entity>
+    <!-- entity class="NoPackageEntity" name="ALighter" access="FIELD" metadata-complete="true">
+        <attributes>
+            <id name="id"/>
+            <basic name="name"/>
+        </attributes>
+    </entity -->
+    <embeddable class="NoPackageEntity" access="FIELD">
+        <attributes>
+            <basic name="name"/>
+        </attributes>
+    </embeddable>
 </entity-mappings>
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/ejb/src/test-resources/explicitpar/META-INF/persistence.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb/src/test-resources/explicitpar/META-INF/persistence.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb/src/test-resources/explicitpar/META-INF/persistence.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -9,6 +9,7 @@
         <class>org.hibernate.ejb.test.Distributor</class>
         <class>org.hibernate.ejb.test.Item</class>
         <class>org.hibernate.ejb.test</class>
+        <exclude-unlisted-classes>true</exclude-unlisted-classes>
         <properties>
             <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
             <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/build.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/build.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/build.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -14,7 +14,7 @@
 
 	<!-- Name of project and version, used to create filenames -->
 	<property name="name" value="ejb3-persistence"/>
-	<property name="version" value="public-draft"/>
+	<property name="version" value="3.0 Final Release"/>
 
 	<!-- set global properties for this build -->
 	<property name="src.dir" value="src"/>

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/etc/license.txt
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/etc/license.txt	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/etc/license.txt	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,84 +1,119 @@
-Copyright 2004-2005 Sun Microsystems, Inc.
+Specification: JSR-000220 Enterprise JavaBeans v.3.0 ("Specification")
+Version: 3.0
+Status: Final Release
+Release: 8 May 2006
+Copyright 2006 SUN MICROSYSTEMS, INC.
 4150 Network Circle, Santa Clara, California 95054, U.S.A
 All rights reserved.
-NOTICE: The Specification is protected by copyright and the information described therein may be protected
-by one or more U.S. patents, foreign patents, or pending applications. Except as provided under
-the following license, no part of the Specification may be reproduced in any form by any means without
-the prior written authorization of Sun Microsystems, Inc. ("Sun") and its licensors, if any. Any use of the
-Specification and the information described therein will be governed by the terms and conditions of this
-Agreement.
-Subject to the terms and conditions of this license, Sun hereby grants you a fully-paid, non-exclusive,
-non-transferable, limited license (without the right to sublicense) under Sun's intellectual property rights
-to review the Specification only for the purposes of evaluation. This license includes the right to discuss
-the Specification (including the right to provide limited excerpts of text to the extent relevant to the
-point[s] under discussion) with other licensees (under this or a substantially similar version of this Agreement)
-of the Specification. Other than this limited license, you acquire no right, title or interest in or to
-the Specification or any other Sun intellectual property, and the Specification may only be used in accordance
-with the license terms set forth herein. This license will expire on the earlier of: (i) two (2) years
-from the date of Release listed above; (ii) the date on which the final version of the Specification is publicly
-released; or (iii) the date on which the Java Specification Request (JSR) to which the Specification
-corresponds is withdrawn. In addition, this license will terminate immediately without notice from Sun
-if you fail to comply with any provision of this license. Upon termination, you must cease use of or destroy
-the Specification.
-TRADEMARKS: No right, title, or interest in or to any trademarks, service marks, or trade names of Sun,
-Sun's licensors, Specification Lead or the Specification Lead's licensors is granted hereunder. Sun, Sun
-Microsystems, the Sun logo, Java, J2SE, J2EE, J2ME, Java Compatible, the Java Compatible Logo, and
-the Java Coffee Cup logo are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S.
-and other countries.
-DISCLAIMER OF WARRANTIES: THE SPECIFICATION IS PROVIDED "AS IS" AND IS EXPERIMENTAL
-AND MAY CONTAIN DEFECTS OR DEFICIENCIES WHICH CANNOT OR WILL
-NOT BE CORRECTED BY SUN. SUN MAKES NO REPRESENTATIONS OR WARRANTIES, EITHER
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT THAT
-THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE OR THAT
-ANY PRACTICE OR IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY
-THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER RIGHTS. This document
-does not represent any commitment to release or implement any portion of the Specification in any product.
-THE SPECIFICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL
-ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION THEREIN; THESE
-CHANGES WILL BE INCORPORATED INTO NEW VERSIONS OF THE SPECIFICATION, IF
-ANY. SUN MAY MAKE IMPROVEMENTS AND/OR CHANGES TO THE PRODUCT(S) AND/OR
-THE PROGRAM(S) DESCRIBED IN THE SPECIFICATION AT ANY TIME. Any use of such changEnterprise
-JavaBeans 3.0, Early Draft Sun Microsystems, Inc.
-3 6/24/04
-es in the Specification will be governed by the then-current license for the applicable version of the Specification.
-LIMITATION OF LIABILITY: TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT
-WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT
-LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL,
-INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS
-OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY
-FURNISHING, PRACTICING, MODIFYING OR ANY USE OF THE SPECIFICATION, EVEN IF
-SUN AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-You will hold Sun (and its licensors) harmless from any claims based on your use of the Specification
-for any purposes other than the limited right of evaluation as described above, and from any claims that
-later versions or releases of any Specification furnished to you are incompatible with the Specification
-provided to you under this license.
-RESTRICTED RIGHTS LEGEND: If this Software is being acquired by or on behalf of the U.S. Government
-or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government's
-rights in the Specification and accompanying documentation shall be only as set forth in this license; this
-is in accordance with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions)
-and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
-REPORT: You may wish to report any ambiguities, inconsistencies or inaccuracies you may find in connection
-with your evaluation of the Specification ("Feedback"). To the extent that you provide Sun with
-any Feedback, you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential
-basis, and (ii) grant Sun a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license,
-with the right to sublicense through multiple levels of sublicensees, to incorporate, disclose, and use
-without limitation the Feedback for any purpose related to the Specification and future versions, implementations,
-and test suites thereof.
-GENERAL TERMS: Any action related to this Agreement will be governed by California law and controlling
-U.S. federal law. The U.N. Convention for the International Sale of Goods and the choice of law
-rules of any jurisdiction will not apply.
+LIMITED LICENSE GRANTS
+1. _License for Evaluation Purposes_. Sun hereby grants you a fully-paid, non-exclusive, non-transferable,
+worldwide, limited license (without the right to sublicense), under Sun’s applicable intellectual
+property rights to view, download, use and reproduce the Specification only for the purpose of internal
+evaluation. This includes (i) developing applications intended to run on an implementation of the Specification,
+provided that such applications do not themselves implement any portion(s) of the Specification,
+and (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the
+Specification in oral or written communications which discuss the Specification provided that such excerpts
+do not in the aggregate constitute a significant portion of the Specification.
+2. _License for the Distribution of Compliant Implementations_. Sun also grants you a perpetual, nonexclusive,
+non-transferable, worldwide, fully paid-up, royalty free, limited license (without the right to
+sublicense) under any applicable copyrights or, subject to the provisions of subsection 4 below, patent
+rights it may have covering the Specification to create and/or distribute an Independent Implementation
+of the Specification that: (a) fully implements the Specification including all its required interfaces and
+functionality; (b) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include
+any public or protected packages, classes, Java interfaces, fields or methods within the Licensor
+Name Space other than those required/authorized by the Specification or Specifications being implemented;
+and (c) passes the Technology Compatibility Kit (including satisfying the requirements of the
+applicable TCK Users Guide) for such Specification ("Compliant Implementation"). In addition, the
+foregoing license is expressly conditioned on your not acting outside its scope. No license is granted
+hereunder for any other purpose (including, for example, modifying the Specification, other than to the
+extent of your fair use rights, or distributing the Specification to third parties). Also, no right, title, or
+interest in or to any trademarks, service marks, or trade names of Sun or Sun’s licensors is granted hereunder.
+Java, and Java-related logos, marks and names are trademarks or registered trademarks of Sun Microsystems,
+Inc. in the U.S. and other countries.
+3. _Pass-through Conditions_. You need not include limitations (a)-(c) from the previous paragraph or
+any other particular "pass through" requirements in any license You grant concerning the use of your Independent
+Implementation or products derived from it. However, except with respect to Independent Implementations
+(and products derived from them) that satisfy limitations (a)-(c) from the previous
+paragraph, You may neither: (a) grant or otherwise pass through to your licensees any licenses under
+Sun’s applicable intellectual property rights; nor (b) authorize your licensees to make any claims concerning
+their implementation’s compliance with the Specification in question.
+4. _Reciprocity Concerning Patent Licenses_.
+a. With respect to any patent claims covered by the license granted under subparagraph 2 above that
+would be infringed by all technically feasible implementations of the Specification, such license is conditioned
+upon your offering on fair, reasonable and non-discriminatory terms, to any party seeking it
+from You, a perpetual, non-exclusive, non-transferable, worldwide license under Your patent rights
+which are or would be infringed by all technically feasible implementations of the Specification to develop,
+distribute and use a Compliant Implementation.
+b With respect to any patent claims owned by Sun and covered by the license granted under subparagraph
+2, whether or not their infringement can be avoided in a technically feasible manner when implementing
+the Specification, such license shall terminate with respect to such claims if You initiate a claim against
+Sun that it has, in the course of performing its responsibilities as the Specification Lead, induced any other
+entity to infringe Your patent rights.
+c Also with respect to any patent claims owned by Sun and covered by the license granted under subparagraph
+2 above, where the infringement of such claims can be avoided in a technically feasible manner
+when implementing the Specification such license, with respect to such claims, shall terminate if You
+initiate a claim against Sun that its making, having made, using, offering to sell, selling or importing a
+Compliant Implementation infringes Your patent rights.
+5. _Definitions_. For the purposes of this Agreement: "Independent Implementation" shall mean an implementation
+of the Specification that neither derives from any of Sun’s source code or binary code materials
+nor, except with an appropriate and separate license from Sun, includes any of Sun’s source code
+or binary code materials; "Licensor Name Space" shall mean the public class or interface declarations
+whose names begin with "java", "javax", "com.sun" or their equivalents in any subsequent naming convention
+adopted by Sun through the Java Community Process, or any recognized successors or replacements
+thereof; and "Technology Compatibility Kit" or "TCK" shall mean the test suite and
+accompanying TCK User’s Guide provided by Sun which corresponds to the Specification and that was
+available either (i) from Sun 120 days before the first release of Your Independent Implementation that
+allows its use for commercial purposes, or (ii) more recently than 120 days from such release but against
+which You elect to test Your implementation of the Specification.
+This Agreement will terminate immediately without notice from Sun if you breach the Agreement or act
+outside the scope of the licenses granted above.
+DISCLAIMER OF WARRANTIES
+THE SPECIFICATION IS PROVIDED "AS IS". SUN MAKES NO REPRESENTATIONS OR WARRANTIES,
+EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT
+(INCLUDING AS A CONSEQUENCE OF ANY PRACTICE OR IMPLEMENTATION
+OF THE SPECIFICATION), OR THAT THE CONTENTS OF THE SPECIFICATION ARE
+SUITABLE FOR ANY PURPOSE. This document does not represent any commitment to release or implement
+any portion of the Specification in any product. In addition, the Specification could include technical
+inaccuracies or typographical errors.
+LIMITATION OF LIABILITY
+TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL SUN OR ITS LICENSORS
+BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE,
+PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ARISING OUT OF OR RELATED IN ANY WAY TO YOUR HAVING, IMPLEMENTING OR
+OTHERWISE USING THE SPECIFICATION, EVEN IF SUN AND/OR ITS LICENSORS HAVE
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+You will indemnify, hold harmless, and defend Sun and its licensors from any claims arising or resulting
+from: (i) your use of the Specification; (ii) the use or distribution of your Java application, applet and/or
+implementation; and/or (iii) any claims that later versions or releases of any Specification furnished to
+you are incompatible with the Specification provided to you under this license.
+
+RESTRICTED RIGHTS LEGEND
+U.S. Government: If this Specification is being acquired by or on behalf of the U.S. Government or by a
+U.S. Government prime contractor or subcontractor (at any tier), then the Government’s rights in the
+Software and accompanying documentation shall be only as set forth in this license; this is in accordance
+with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with
+48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
+REPORT
+If you provide Sun with any comments or suggestions concerning the Specification ("Feedback"), you
+hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii)
+grant Sun a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense
+through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the
+Feedback for any purpose.
+GENERAL TERMS
+Any action related to this Agreement will be governed by California law and controlling U.S. federal law.
+The U.N. Convention for the International Sale of Goods and the choice of law rules of any jurisdiction
+will not apply.
 The Specification is subject to U.S. export control laws and may be subject to export or import regulations
 in other countries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges
 that it has the responsibility to obtain such licenses to export, re-export or import as may be
 required after delivery to Licensee.
-Neither party may assign or otherwise transfer any of its rights or obligations under this Agreement, without
-the prior written consent of the other party, except that Sun may assign this Agreement to an affiliated
-company.
-This Agreement is the parties' entire agreement relating to its subject matter. It supersedes all prior or
+This Agreement is the parties’ entire agreement relating to its subject matter. It supersedes all prior or
 contemporaneous oral or written communications, proposals, conditions, representations and warranties
 and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication
 between the parties relating to its subject matter during the term of this Agreement. No modification
 to this Agreement will be binding, unless in writing and signed by an authorized representative
 of each party.
-(Sun.pSpec.license.11.14.2003)
\ No newline at end of file
+Rev. April, 2006
+Sun/Final/Full
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AssociationOverride.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AssociationOverride.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AssociationOverride.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,4 +1,5 @@
-//$Id: $
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Target;
@@ -9,10 +10,25 @@
 import static java.lang.annotation.ElementType.FIELD;
 
 /**
+ * This annotation is used to override a many-to-one or one-to-one mapping of property or field for
+ * an entity relationship.
+ * The AssociationOverride annotation may be applied to an entity that extends a mapped superclass
+ * to override a many-to-one or one-to-one mapping defined by the mapped superclass. If the
+ * AssociationOverride annotation is not specified, the join column is mapped the same as in
+ * the original mapping.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
 public @interface AssociationOverride {
+	/**
+	 * The name of the relationship property whose mapping is being overridden if property-based
+	 * access is being used, or the name of the relationship field if field-based access is used.
+	 */
 	String name();
+
+	/**
+	 * The join column that is being mapped to the persistent attribute.
+	 */
 	JoinColumn[] joinColumns();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AssociationOverrides.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AssociationOverrides.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AssociationOverrides.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,4 +1,5 @@
-//$Id: $
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Target;
@@ -9,9 +10,15 @@
 import static java.lang.annotation.ElementType.FIELD;
 
 /**
+ * This annotation is used to override mappings of multiple many-to-one
+ * or one-to-one relationship properties or fields.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
 public @interface AssociationOverrides {
+	/**
+	 * Mapping overrides of relationship properties or fields
+	 */
 	AssociationOverride[] value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AttributeOverride.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AttributeOverride.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AttributeOverride.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -10,10 +10,25 @@
 
 
 /**
+ * The AttributeOverride annotation is used to override the mapping of a Basic (whether explicit
+ * or default) property or field or Id property or field.
+ *
+ * The AttributeOverride annotation may be applied to an entity that extends a mapped superclass
+ * or to an embedded field or property to override a basic mapping defined by the mapped superclass
+ * or embeddable class. If the AttributeOverride annotation is not specified, the column is mapped
+ * the same as in the original mapping.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
 public @interface AttributeOverride {
+	/**
+	 * The column that is being mapped to the persistent attribute
+	 */
 	String name();
+	/**
+	 * The name of the property whose mapping is being overridden if property-based access is being
+	 * used, or the name of the field if field-based access is used.
+	 */
 	Column column();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AttributeOverrides.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AttributeOverrides.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/AttributeOverrides.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -10,9 +10,14 @@
 
 
 /**
+ * Is used to override mappings of multiple properties or fields
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
 public @interface AttributeOverrides {
+	/**
+	 * One or more mapping override
+	 */
 	AttributeOverride[] value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Basic.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Basic.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Basic.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import static java.lang.annotation.ElementType.FIELD;
@@ -10,10 +10,30 @@
 import static javax.persistence.FetchType.EAGER;
 
 /**
+ * The Basic annotation is the simplest type of mapping to a database column. The Basic
+ * annotation can be applied to a persistent property or instance variable of any of the
+ * following types: Java primitive types, wrappers of the primitive types, String,
+ * java.math.BigInteger, java.math.BigDecimal, java.util.Date, java.util.Calendar,
+ * java.sql.Date, java.sql.Time, java.sql.Timestamp, byte[], Byte[], char[], Character[],
+ * enums, and any other type that implements Serializable.
+ *
+ * The use of the Basic annotation is optional for persistent fields and properties of these types.
+
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)
 public @interface Basic {
+	/**
+	 * Defines whether the value of the field or property should be lazily loaded or must be
+	 * eagerly fetched. The EAGER strategy is a requirement on the persistence provider runtime
+	 * that the value must be eagerly fetched. The LAZY strategy is a hint to the persistence
+	 * provider runtime. If not specified, defaults to EAGER.
+	 */
 	FetchType fetch() default EAGER;
+	/**
+	 * Defines whether the value of the field or property may be null. This is a hint and is
+	 * disregarded for primitive types; it may be used in schema generation. If not specified,
+	 * defaults to true.
+	 */
 	boolean optional() default true;
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/CascadeType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/CascadeType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/CascadeType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,8 +1,32 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 /**
+ * Defines the set of cascadable operations that are propagated to the associated entity.
+ * The value cascade=ALL is equivalent to cascade={PERSIST, MERGE, REMOVE, REFRESH}.
+ *
  * @author Emmanuel Bernard
  */
-public enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REFRESH };
+public enum CascadeType {
+	/**
+	 * Cascade all operations
+	 */
+	ALL,
+	/**
+	 * Cascade persist operations
+	 */
+	PERSIST,
+	/**
+	 * Cascade merge operations
+	 */
+	MERGE,
+	/**
+	 * Cascade remove operations
+	 */
+	REMOVE,
+	/**
+	 * Cascade refresh operations
+	 */
+	REFRESH 
+}

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Column.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Column.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Column.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,18 +9,57 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * Is used to specify a mapped column for a persistent property or field. If no Column annotation is
+ * specified, the default values are applied.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)
 public @interface Column {
+	/**
+	 * The name of the column. Defaults to the property or field name
+	 */
 	String name() default "";
+	/**
+	 * Whether the property is a unique key. This is a shortcut for the UniqueConstraint
+	 * annotation at the table level and is useful for when the unique key constraint is
+	 * only a single field. This constraint applies in addition to any constraint entailed
+	 * by primary key mapping and to constraints specified at the table level.
+	 */
 	boolean unique() default false;
+	/**
+	 * Whether the database column is nullable
+	 */
 	boolean nullable() default true;
+	/**
+	 * Whether the column is included in SQL INSERT statements generated by the persistence provider.
+	 */
 	boolean insertable() default true;
+	/**
+	 * Whether the column is included in SQL UPDATE statements generated by the persistence provider.
+	 */
 	boolean updatable() default true;
+	/**
+	 * The SQL fragment that is used when generating the DDL for the column.
+	 * Defaults to the generated SQL to create a column of the inferred type.
+	 */
 	String columnDefinition() default "";
+	/**
+	 * The name of the table that contains the column. If absent the column is assumed to
+	 * be in the primary table.
+	 */
 	String table() default "";
+	/**
+	 * The column length. (Applies only if a string-valued column is used.)
+	 */
 	int length() default 255;
-	int precision() default 0; // decimal precision
-	int scale() default 0; // decimal scale
+	/**
+	 * The precision for a decimal (exact numeric) column. (Applies only if a decimal column is used.)
+	 * Value must be set by developer if used when generating the DDL for the column.
+	 */
+	int precision() default 0;
+	/**
+	 * The scale for a decimal (exact numeric) column. (Applies only if a decimal column is used.)
+	 */
+	int scale() default 0;
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ColumnResult.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ColumnResult.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ColumnResult.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Target;
@@ -7,9 +7,16 @@
 import java.lang.annotation.RetentionPolicy;
 
 /**
+ * References name of a column in the SELECT clause of a SQL query - i.e.,
+ * column alias, if applicable. Scalar result types can be included in the query
+ * result by specifying this annotation in the metadata.
+ *
  * @author Emmanuel Bernard
  */
 @Target({}) @Retention(RetentionPolicy.RUNTIME)
 public @interface ColumnResult {
+	/**
+	 * The name of a column in the SELECT clause of a SQL query
+	 */
 	String name();
 }
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorColumn.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorColumn.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorColumn.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -10,12 +10,38 @@
 import static javax.persistence.DiscriminatorType.STRING;
 
 /**
+ * Is used to define the discriminator column for the SINGLE_TABLE and JOINED inheritance
+ * mapping strategies.
+ *
+ * The strategy and the discriminator column are only specified in the root of an entity
+ * class hierarchy or subhierarchy in which a different inheritance strategy is applied
+ *
+ * If the DiscriminatorColumn annotation is missing, and a discriminator column is required,
+ * the name of the discriminator column defaults to "DTYPE" and the discriminator type to
+ * DiscriminatorType.STRING.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE}) @Retention(RUNTIME)
 public @interface DiscriminatorColumn {
+	/**
+	 * The name of column to be used for the discriminator.
+	 */
 	String name() default "DTYPE";
+	/**
+	 * The type of object/column to use as a class discriminator.
+	 * Defaults to DiscriminatorType.STRING
+	 */
 	DiscriminatorType discriminatorType() default STRING;
+	/**
+	 * The SQL fragment that is used when generating the DDL for the discriminator column.
+	 * Defaults to the provider-generated SQL to create a column of the specified
+	 * discriminator type.
+	 */
 	String columnDefinition() default "";
+	/**
+	 * The column length for String-based discriminator types. Ignored for other
+	 * discriminator types.
+	 */
 	int length() default 31;
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,8 +1,23 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 /**
+ * Defines supported types of the discriminator column
+ *
  * @author Emmanuel Bernard
  */
-public enum DiscriminatorType { STRING, CHAR, INTEGER };
+public enum DiscriminatorType {
+	/**
+	 * String as the discriminator type
+	 */
+	STRING,
+	/**
+	 * Single character as the discriminator type
+	 */
+	CHAR,
+	/**
+	 * Integer as the discriminator type
+	 */
+	INTEGER
+};

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorValue.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorValue.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorValue.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -7,9 +7,27 @@
 import static java.lang.annotation.ElementType.TYPE;
 
 /**
+ * Is used to specify the value of the discriminator column for entities of the given type.
+ * The DiscriminatorValue annotation can only be specified on a concrete entity class.
+ * If the DiscriminatorValue annotation is not specified and a discriminator column is used,
+ * a provider-specific function will be used to generate a value representing the entity type.
+ * If the DiscriminatorType is STRING, the discriminator value default is the entity name.
+ *
+ * The inheritance strategy and the discriminator column are only specified in the root
+ * of an entity class hierarchy or subhierarchy in which a different inheritance strategy
+ * is applied. The discriminator value, if not defaulted, should be specified for each entity
+ * class in the hierarchy.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE}) @Retention(RUNTIME)
 public @interface DiscriminatorValue {
+	/**
+	 * The value that indicates that the row is an entity of the annotated entity type.
+	 * 
+	 * If the DiscriminatorValue annotation is not specified and a discriminator column is used,
+	 * a provider-specific function will be used to generate a value representing the entity type.
+	 * If the DiscriminatorType is STRING, the discriminator value default is the entity name.
+	 */
 	String value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Embeddable.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Embeddable.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Embeddable.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -10,6 +10,12 @@
 
 
 /**
+ * Defines a class whose instances are stored as an intrinsic part of an owning entity and share
+ * the identity of the entity. Each of the persistent properties or fields of the embedded object
+ * is mapped to the database table for the entity. Only Basic, Column, Lob, Temporal, and
+ * Enumerated mapping annotations may portably be used to map the persistent fields or properties
+ * of classes annotated as Embeddable.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE}) @Retention(RUNTIME)

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Embedded.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Embedded.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Embedded.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -9,6 +9,9 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * Defines a persistent field or property of an entity whose value is an instance of
+ * an embeddable class. The embeddable class must be annotated as Embeddable.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EmbeddedId.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EmbeddedId.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EmbeddedId.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.ElementType;
@@ -8,6 +8,10 @@
 import java.lang.annotation.Target;
 
 /**
+ * Is applied to a persistent field or property of an entity class or mapped superclass to denote
+ * a composite primary key that is an embeddable class. The embeddable class must be annotated
+ * as Embeddable.
+ * 
  * @author Emmanuel Bernard
  */
 @Target({ElementType.METHOD, ElementType.FIELD})

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Entity.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Entity.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Entity.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import static java.lang.annotation.ElementType.TYPE;
@@ -8,9 +8,16 @@
 import java.lang.annotation.Target;
 
 /**
+ * Specifies that the class is an entity. This annotation is applied to the entity class.
+ *
  * @author Emmanuel Bernard
  */
 @Target(TYPE) @Retention(RUNTIME)
 public @interface Entity {
+	/**
+	 * The name of an entity. Defaults to the unqualified name of the entity class.
+	 * This name is used to refer to the entity in queries. The name must not be a
+	 * reserved literal in the Java Persistence query language.
+	 */
 	String name() default "";
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityExistsException.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityExistsException.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityExistsException.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,21 +2,43 @@
 package javax.persistence;
 
 /**
+ * Thrown by the persistence provider when EntityManager.persist(Object) is called and the
+ * entity already exists. The current transaction, if one is active, will be marked for rollback.
+ *
  * @author Emmanuel Bernard
  */
 public class EntityExistsException extends PersistenceException {
+	/**
+	 * Constructs a new EntityExistsException exception with null as its detail message.
+	 */
 	public EntityExistsException() {
 		super();
 	}
 
+	/**
+	 * Constructs a new EntityExistsException exception with the specified cause.
+	 *
+	 * @param cause the cause
+	 */
 	public EntityExistsException(Throwable cause) {
 		super( cause );
 	}
 
+	/**
+	 * Constructs a new EntityExistsException exception with the specified detail message.
+	 *
+	 * @param message the detail message.
+	 */
 	public EntityExistsException(String message) {
 		super( message );
 	}
 
+	/**
+	 * Constructs a new EntityExistsException exception with the specified detail message and cause.
+	 *
+	 * @param message the detail message.
+	 * @param cause the cause.
+	 */
 	public EntityExistsException(String message, Throwable cause) {
 		super( message, cause );
 	}

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityListeners.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityListeners.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityListeners.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -13,12 +13,16 @@
 
 
 /**
- * comment
+ * Specifies the callback listener classes to be used for an entity or mapped superclass.
+ * This annotation may be applied to an entity class or mapped superclass.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  */
 @Target({ElementType.TYPE})
 @Retention(RetentionPolicy.RUNTIME)
 public @interface EntityListeners {
+	/**
+	 * The callback listener classes
+	 */
    Class[] value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityManager.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityManager.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityManager.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -3,10 +3,23 @@
 
 /**
  * Interface used to interact with the persistence context.
+ *
+ * An EntityManager instance is associated with a persistence context. A persistence context is a set of
+ * entity instances in which for any persistent entity identity there is a unique entity instance.
+ * Within the persistence context, the entity instances and their lifecycle are managed. This interface
+ * defines the methods that are used to interact with the persistence context. The EntityManager API is
+ * used to create and remove persistent entity instances, to find entities by their primary key, and to
+ * query over entities.
+ *
+ * The set of entities that can be managed by a given EntityManager instance is defined by a persistence unit.
+ * A persistence unit defines the set of all classes that are related or grouped by the application, and
+ * which must be colocated in their mapping to a single database.
+ *
+ * @author Emmanuel Bernard
  */
 public interface EntityManager {
 	/**
-	 * Make an instance managed and persistent.
+	 * Make an entity instance managed and persistent.
 	 *
 	 * @param entity
 	 * @throws EntityExistsException		if the entity already exists.
@@ -14,6 +27,7 @@
 	 *                                      operation is invoked, or the EntityExistsException or
 	 *                                      another PersistenceException may be thrown at commit
 	 *                                      time.)
+	 * @throws IllegalStateException if this EntityManager has been closed.
 	 * @throws IllegalArgumentException	 if not an entity
 	 * @throws TransactionRequiredException if invoked on a
 	 *                                      container-managed entity manager of type
@@ -28,6 +42,7 @@
 	 *
 	 * @param entity
 	 * @return the instance that the state was merged to
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 * @throws IllegalArgumentException	 if instance is not an
 	 *                                      entity or is a removed entity
 	 * @throws TransactionRequiredException if invoked on a
@@ -41,6 +56,7 @@
 	 * Remove the entity instance.
 	 *
 	 * @param entity
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 * @throws IllegalArgumentException	 if not an entity
 	 *                                      or if a detached entity
 	 * @throws TransactionRequiredException if invoked on a
@@ -57,6 +73,7 @@
 	 * @param primaryKey
 	 * @return the found entity instance or null
 	 *         if the entity does not exist
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 * @throws IllegalArgumentException if the first argument does
 	 *                                  not denote an entity type or the second
 	 *                                  argument is not a valid type for that
@@ -78,6 +95,7 @@
 	 * @param entityClass
 	 * @param primaryKey
 	 * @return the found entity instance
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 * @throws IllegalArgumentException if the first argument does
 	 *                                  not denote an entity type or the second
 	 *                                  argument is not a valid type for that
@@ -91,6 +109,7 @@
 	 * Synchronize the persistence context to the
 	 * underlying database.
 	 *
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 * @throws TransactionRequiredException if there is
 	 *                                      no transaction
 	 * @throws PersistenceException		 if the flush fails
@@ -102,6 +121,7 @@
 	 * in the persistence context.
 	 *
 	 * @param flushMode
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 */
 	public void setFlushMode(FlushModeType flushMode);
 
@@ -110,6 +130,7 @@
 	 * in the persistence context.
 	 *
 	 * @return flushMode
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 */
 	public FlushModeType getFlushMode();
 
@@ -119,6 +140,7 @@
 	 *
 	 * @param entity
 	 * @param lockMode
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 * @throws PersistenceException		 if an unsupported lock call
 	 *                                      is made
 	 * @throws IllegalArgumentException	 if the instance is not
@@ -133,6 +155,7 @@
 	 * overwriting changes made to the entity, if any.
 	 *
 	 * @param entity
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 * @throws IllegalArgumentException	 if not an entity
 	 *                                      or entity is not managed
 	 * @throws TransactionRequiredException if invoked on a
@@ -149,6 +172,8 @@
 	 * entities to become detached. Changes made to entities that
 	 * have not been flushed to the database will not be
 	 * persisted.
+	 *
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 */
 	public void clear();
 
@@ -157,7 +182,8 @@
 	 * context.
 	 *
 	 * @param entity
-	 * @return
+	 * @return <code>true</code> if the instance belongs to the current persistence context.
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 * @throws IllegalArgumentException if not an entity
 	 */
 	public boolean contains(Object entity);
@@ -168,6 +194,7 @@
 	 *
 	 * @param ejbqlString an EJB QL query string
 	 * @return the new query instance
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 * @throws IllegalArgumentException if query string is not valid
 	 */
 	public Query createQuery(String ejbqlString);
@@ -178,6 +205,7 @@
 	 *
 	 * @param name the name of a query defined in metadata
 	 * @return the new query instance
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 * @throws IllegalArgumentException if a query has not been
 	 *                                  defined with the given name
 	 */
@@ -189,6 +217,7 @@
 	 *
 	 * @param sqlString a native SQL query string
 	 * @return the new query instance
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 */
 	public Query createNativeQuery(String sqlString);
 
@@ -199,6 +228,7 @@
 	 * @param sqlString   a native SQL query string
 	 * @param resultClass the class of the resulting instance(s)
 	 * @return the new query instance
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 */
 	public Query createNativeQuery(String sqlString, Class resultClass);
 
@@ -209,6 +239,7 @@
 	 * @param sqlString		a native SQL query string
 	 * @param resultSetMapping the name of the result set mapping
 	 * @return the new query instance
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 */
 	public Query createNativeQuery(String sqlString, String resultSetMapping);
 
@@ -219,6 +250,7 @@
 	 * of the active transaction to associate it with the current
 	 * JTA transaction.
 	 *
+	 * @throws IllegalStateException if this EntityManager has been closed
 	 * @throws TransactionRequiredException if there is
 	 *                                      no transaction.
 	 */
@@ -228,7 +260,7 @@
     * Return the underlying provider object for the EntityManager, if available.
     * The result of this method is implementation specific
     *
-    * @return
+    * @throws IllegalStateException if this EntityManager has been closed
     */
    public Object getDelegate();
 
@@ -242,8 +274,7 @@
 	 * associated with an active transaction, the persistence
 	 * context remains managed until the transaction completes.
 	 *
-	 * @throws IllegalStateException if the EntityManager
-	 *                               is container-managed.
+	 * @throws IllegalStateException if the EntityManager is container-managed or has been already closed
 	 */
 	public void close();
 

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityManagerFactory.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityManagerFactory.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityManagerFactory.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -3,6 +3,15 @@
 
 import java.util.Map;
 
+/**
+ * The EntityManagerFactory interface is used by the application to obtain an
+ * application-managed entity manager. When the application has finished using
+ * the entity manager factory, and/or at application shutdown, the application
+ * should close the entity manager factory. Once an EntityManagerFactory has been
+ * closed, all its entity managers are considered to be in the closed state.
+ *
+ * @author Emmanuel Bernard
+ */
 public interface EntityManagerFactory {
 
 	/**
@@ -33,8 +42,8 @@
 	void close();
 
 	/**
-	 * Indicates whether the factory is open. Returns true
-	 * until the factory has been closed.
+	 * Indicates whether or not this factory is open. Returns
+	 * true until a call to close has been made.
 	 */
 	public boolean isOpen();
 }
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityNotFoundException.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityNotFoundException.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityNotFoundException.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,24 +2,28 @@
 package javax.persistence;
 
 /**
+ * Thrown by the persistence provider when an entity reference obtained by
+ * EntityManager.getReference(Class,Object)  is accessed but the entity does not exist.
+ * Also thrown when EntityManager.refresh(Object) is called and the object no longer exists
+ * in the database. The current transaction, if one is active, will be marked for rollback.
+ *
  * @author Gavin King
  */
 public class EntityNotFoundException extends PersistenceException {
-
+	/**
+	 * Constructs a new EntityNotFoundException exception with null as its detail message.
+	 */
 	public EntityNotFoundException() {
 		super();
 	}
 
-	public EntityNotFoundException(String message, Throwable cause) {
-		super( message, cause );
-	}
-
+	/**
+	 * Constructs a new EntityNotFoundException exception with the specified detail message.
+	 *
+	 * @param message the detail message
+	 */
 	public EntityNotFoundException(String message) {
 		super( message );
 	}
 
-	public EntityNotFoundException(Throwable cause) {
-		super( cause );
-	}
-
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityResult.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityResult.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityResult.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Target;
@@ -7,11 +7,27 @@
 import java.lang.annotation.RetentionPolicy;
 
 /**
+ * References an entity in the SELECT clause of a SQL query. If this annotation is used,
+ * the SQL statement should select all of the columns that are mapped to the entity object.
+ * This should include foreign key columns to related entities. The results obtained when
+ * insufficient data is available are undefined.
+ *
  * @author Emmanuel Bernard
  */
 @Target({}) @Retention(RetentionPolicy.RUNTIME)
 public @interface EntityResult {
+	/**
+	 * The class of the result
+	 */
 	Class entityClass();
+	/**
+	 * Maps the columns specified in the SELECT list of the query to the properties or
+	 * fields of the entity class.
+	 */
 	FieldResult[] fields() default {};
+	/**
+	 * Specifies the column name (or alias) of the column in the SELECT list that is used to
+	 * determine the type of the entity instance.
+	 */
 	String discriminatorColumn() default "";
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityTransaction.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityTransaction.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EntityTransaction.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,6 +1,13 @@
 //$Id$
 package javax.persistence;
 
+/**
+ * The EntityTransaction interface is used to control resource transactions
+ * on resource-local entity managers. The EntityManager.getTransaction()
+ * method returns the EntityTransaction interface.
+ *
+ * @author Emmanuel Bernard
+ */
 public interface EntityTransaction {
 	/**
 	 * Start a resource transaction.

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EnumType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EnumType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/EnumType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,9 +2,18 @@
 package javax.persistence;
 
 /**
+ * Defines mapping for the enumerated types. The constants of this enumerated type specify how persistent
+ * property or field should be persisted as a enumerated type.
+ *
  * @author Emmanuel Bernard
  */
 public enum EnumType {
+	/**
+	 * Persist enumerated type property or field as an integer
+	 */
 	ORDINAL,
+	/**
+	 * Persist enumerated type property or field as a string
+	 */
 	STRING
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Enumerated.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Enumerated.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Enumerated.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -9,10 +9,16 @@
 import static javax.persistence.EnumType.*;
 
 /**
+ * Specifies that a persistent property or field should be persisted as a enumerated type.
+ * It may be used in conjunction with the Basic annotation.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD})
 @Retention(RUNTIME)
 public @interface Enumerated {
+	/**
+	 * The type used in mapping an enum type
+	 */
 	EnumType value() default ORDINAL;
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ExcludeDefaultListeners.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ExcludeDefaultListeners.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ExcludeDefaultListeners.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -7,6 +7,9 @@
 import java.lang.annotation.Target;
 
 /**
+ * Specifies that the invocation of default listeners is to be excluded for the entity class
+ * (or mapped superclass) and its subclasses.
+ *
  * @author Emmanuel Bernard
  */
 @Target(TYPE) @Retention(RUNTIME)

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ExcludeSuperclassListeners.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ExcludeSuperclassListeners.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ExcludeSuperclassListeners.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -7,6 +7,9 @@
 import static java.lang.annotation.ElementType.TYPE;
 
 /**
+ * Specifies that the invocation of superclass listeners is to be excluded for the
+ * entity class (or mapped superclass) and its subclasses.
+ *
  * @author Emmanuel Bernard
  */
 @Target(TYPE) @Retention(RUNTIME)

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FetchType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FetchType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FetchType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,8 +1,24 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 /**
+ * Defines strategies for fetching data from the database.
+ * The EAGER strategy is a requirement on the persistence provider runtime that data must
+ * be eagerly fetched. The LAZY strategy is a hint to the persistence provider runtime that
+ * data should be fetched lazily when it is first accessed. The implementation is permitted to
+ * eagerly fetch data for which the LAZY strategy hint has been specified. In particular, lazy
+ * fetching might only be available for Basic mappings for which property-based access is used.
+ *
  * @author Emmanuel Bernard
  */
-public enum FetchType { LAZY, EAGER };
+public enum FetchType {
+	/**
+	 * Defines that data must be lazily fetched
+	 */
+	LAZY,
+	/**
+	 * Defines that data must be eagerly fetched
+	 */
+	EAGER
+};

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FieldResult.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FieldResult.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FieldResult.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -7,10 +7,19 @@
 import java.lang.annotation.RetentionPolicy;
 
 /**
+ * Is used to map the columns specified in the SELECT list of the query to the properties
+ * or fields of the entity class.
+ *
  * @author Emmanuel Bernard
  */
 @Target({}) @Retention(RetentionPolicy.RUNTIME)
 public @interface FieldResult {
+	/**
+	 * Name of the persistent field or property of the class.
+	 */
 	String name();
+	/**
+	 * Name of the column in the SELECT clause - i.e., column aliases, if applicable.
+	 */
 	String column();
 }

Deleted: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FlushMode.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FlushMode.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FlushMode.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,24 +0,0 @@
-/*
- * JBoss, the OpenSource EJB server
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package javax.persistence;
-
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
- at Target({METHOD, FIELD}) @Retention(RUNTIME)
-public @interface FlushMode {
-	FlushModeType value() default FlushModeType.AUTO;
-}

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FlushModeType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FlushModeType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/FlushModeType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,9 +2,28 @@
 package javax.persistence;
 
 /**
+ * Flush mode setting.
+ *
+ * When queries are executed within a transaction, if FlushModeType.AUTO is set on the Query object,
+ * or if the flush mode setting for the persistence context is AUTO (the default) and a flush mode
+ * setting has not been specified for the Query object, the persistence provider is responsible for
+ * ensuring that all updates to the state of all entities in the persistence context which could
+ * potentially affect the result of the query are visible to the processing of the query.
+ * The persistence provider implementation may achieve this by flushing those entities to the database
+ * or by some other means. If FlushModeType.COMMIT is set, the effect of updates made to entities in the
+ * persistence context upon queries is unspecified.
+ *
+ * If there is no transaction active, the persistence provider must not flush to the database.
+ *
  * @author Gavin King
  */
-public enum FlushModeType {	
+public enum FlushModeType {
+	/**
+	 * Flushing must occur only at transaction commit
+	 */
 	COMMIT,
+	/**
+	 * (Default) Flushing to occur at query execution
+	 */
 	AUTO
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/GeneratedValue.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/GeneratedValue.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/GeneratedValue.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -8,11 +8,25 @@
 import java.lang.annotation.Target;
 
 /**
+ * Provides for the specification of generation strategies for the values of primary keys.
+ * The GeneratedValue annotation may be applied to a primary key property or field of an entity
+ * or mapped superclass in conjunction with the Id annotation.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD})
 @Retention(RUNTIME)
 public @interface GeneratedValue {
+	/**
+	 * The primary key generation strategy that the persistence provider must use
+	 * to generate the annotated entity primary key.
+	 */
 	GenerationType strategy() default GenerationType.AUTO;
+	/**
+	 * The name of the primary key generator to use as specified in the SequenceGenerator or
+	 * TableGenerator annotation.
+	 *
+	 * Defaults to the id generator supplied by persistence provider. 
+	 */
 	String generator() default "";
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/GenerationType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/GenerationType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/GenerationType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,8 +1,34 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 /**
+ * Defines the types of primary key generation.
+ *
  * @author Emmanuel Bernard
  */
-public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
+public enum GenerationType {
+	/**
+	 * Indicates that the persistence provider must assign primary keys for the entity using an underlying
+	 * database table to ensure uniqueness.
+	 */
+	TABLE,
+	/**
+	 * Indicates that the persistence provider must assign primary keys for the entity using database
+	 * sequence column.
+	 */
+	SEQUENCE,
+	/**
+	 * Indicates that the persistence provider must assign primary keys for the entity using
+	 * database identity column.
+	 */
+	IDENTITY,
+	/**
+	 * Indicates that the persistence provider should pick an appropriate strategy for the
+	 * particular database. The AUTO generation strategy may expect a database resource
+	 * to exist, or it may attempt to create one. A vendor may provide documentation on how
+	 * to create such resources in the event that it does not support schema generation or cannot
+	 * create the schema resource at runtime.
+	 */
+	AUTO
+};

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Id.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Id.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Id.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import static java.lang.annotation.ElementType.FIELD;
@@ -10,6 +10,8 @@
 
 
 /**
+ * Specifies the primary key property or field of an entity.
+ * 
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/IdClass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/IdClass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/IdClass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,9 +9,18 @@
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
 /**
+ * Specifies a composite primary key class that is mapped to multiple fields or properties
+ * of the entity.
+ *
+ * The names of the fields or properties in the primary key class and the primary key fields
+ * or properties of the entity must correspond and their types must be the same.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE}) @Retention(RUNTIME)
 public @interface IdClass {
+	/**
+	 * Primary key class
+	 */
 	Class value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Inheritance.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Inheritance.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Inheritance.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import static java.lang.annotation.ElementType.TYPE;
@@ -9,9 +9,15 @@
 import static javax.persistence.InheritanceType.SINGLE_TABLE;
 
 /**
+ * Defines the inheritance strategy to be used for an entity class hierarchy. It is specified
+ * on the entity class that is the root of the entity class hierarchy.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE}) @Retention(RUNTIME)
 public @interface Inheritance {
+	/**
+	 * The strategy to be used
+	 */
 	InheritanceType strategy() default SINGLE_TABLE;
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/InheritanceType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/InheritanceType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/InheritanceType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,25 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 /**
+ * Defines inheritance strategy options.
+ *
  * @author Emmanuel Bernard
  */
 public enum InheritanceType
-{ SINGLE_TABLE, TABLE_PER_CLASS, JOINED };
+{
+	/**
+	 * A single table per class hierarchy
+	 */
+	SINGLE_TABLE,
+	/**
+	 * A table per concrete entity class
+	 */
+	TABLE_PER_CLASS,
+	/**
+	 * A strategy in which fields that are specific to a subclass are mapped to a separate
+	 * table than the fields that are common to the parent class, and a join is performed
+	 * to instantiate the subclass.
+	 */
+	JOINED };

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinColumn.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinColumn.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinColumn.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,16 +9,59 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * Is used to specify a mapped column for joining an entity association.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)
 public @interface JoinColumn {
+	/**
+	 * The name of the foreign key column.
+	 * The table in which it is found depends upon the context. If the join is for a OneToOne
+	 * or Many- ToOne mapping, the foreign key column is in the table of the source entity.
+	 * If the join is for a ManyToMany, the foreign key is in a join table. Default (only applies
+	 * if a single join column is used): The concatenation of the following: the name of the referencing
+	 * relationship property or field of the referencing entity; "_"; the name of the referenced primary
+	 * key column. If there is no such referencing relationship property or field in the entity, the join
+	 * column name is formed as the concatenation of the following: the name of the entity; "_"; the name
+	 * of the referenced primary key column.
+	 */
 	String name() default "";
+	/**
+	 * The name of the column referenced by this foreign key column. When used with relationship mappings,
+	 * the referenced column is in the table of the target entity. When used inside a JoinTable annotation,
+	 * the referenced key column is in the entity table of the owning entity, or inverse entity if the join
+	 * is part of the inverse join definition. Default (only applies if single join column is being used):
+	 * The same name as the primary key column of the referenced table.
+	 */
 	String referencedColumnName() default "";
+	/**
+	 * Whether the property is a unique key. This is a shortcut for the UniqueConstraint annotation at the
+	 * table level and is useful for when the unique key constraint is only a single field. It is not
+	 * necessary to explicitly specify this for a join column that corresponds to a primary key that is part
+	 * of a foreign key.
+	 */
 	boolean unique() default false;
+	/**
+	 * Whether the foreign key column is nullable
+	 */
 	boolean nullable() default true;
+	/**
+	 * Whether the column is included in SQL INSERT statements generated by the persistence provider
+	 */
 	boolean insertable() default true;
+	/**
+	 * Whether the column is included in SQL UPDATE statements generated by the persistence provider
+	 */
 	boolean updatable() default true;
+	/**
+	 * The SQL fragment that is used when generating the DDL for the column.
+	 * Defaults to the generated SQL for the column.
+	 */
 	String columnDefinition() default "";
+	/**
+	 * The name of the table that contains the column. If a table is not specified, the column is
+	 * assumed to be in the primary table of the applicable entity
+	 */
 	String table() default "";
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinColumns.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinColumns.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinColumns.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,9 +9,15 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * Defines mapping for the composite foreign keys.
+ * This annotation groups JoinColumn annotations for the same relationship.
+ *
+ * When the JoinColumns annotation is used, both the name and the referencedColumnName
+ * elements must be specified in each such JoinColumn annotation.
+
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)
 public @interface JoinColumns {
-    JoinColumn[] value() default {};
+    JoinColumn[] value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinTable.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinTable.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/JoinTable.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,14 +9,55 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * This annotation is used in the mapping of associations. It is specified on the owning
+ * side of a many-to-many association, or in a unidirectional one-to-many association.
+ *
+ * If the JoinTable annotation is missing, the default values of the annotation elements apply.
+ * The name of the join table is assumed to be the table names of the associated primary tables
+ * concatenated together (owning side first) using an underscore.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD})  @Retention(RUNTIME)
 public @interface JoinTable {
+	/**
+	 * The name of the join table.
+	 *
+	 * Defaults to the concatenated names of the two associated primary entity tables,
+	 * separated by an underscore
+	 */
 	String name() default "";
+	/**
+	 * The catalog of the table.
+	 *
+	 * Defaults to the default catalog.
+	 */
 	String catalog() default "";
+	/**
+	 * The schema of the table.
+	 *
+	 * Defaults to the default schema for user.
+	 */
 	String schema() default "";
+	/**
+	 * The foreign key columns of the join table which reference the primary table of the
+	 * entity owning the association (i.e. the owning side of the association).
+	 *
+	 * Uses the same defaults as for JoinColumn.
+	 */
 	JoinColumn[] joinColumns() default {};
+	/**
+	 * The foreign key columns of the join table which reference the primary table of the entity
+	 * that does not own the association (i.e. the inverse side of the association).
+	 *
+	 * Uses the same defaults as for JoinColumn
+	 */
 	JoinColumn[] inverseJoinColumns() default {};
+	/**
+	 * Unique constraints that are to be placed on the table. These are only used if table
+	 * generation is in effect.
+	 *
+	 * Defaults to no additional constraints
+	 */
 	UniqueConstraint[] uniqueConstraints() default {};
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Lob.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Lob.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Lob.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import static java.lang.annotation.ElementType.METHOD;
@@ -12,6 +12,13 @@
 import java.lang.annotation.Retention;
 
 /**
+ * Specifies that a persistent property or field should be persisted as a large object to a
+ * database-supported large object type. The Lob annotation may be used in conjunction with
+ * the Basic annotation. A Lob may be either a binary or character type.
+ *
+ * The Lob type is inferred from the type of the persistent field or property, and except
+ * for string and character-based types defaults to Blob.
+ *  
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/LockModeType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/LockModeType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/LockModeType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,9 +2,39 @@
 package javax.persistence;
 
 /**
+ * Lock modes that can be specified by means of the EntityManager.lock() method.
+ *
+ * The semantics of requesting locks of type LockModeType.READ and LockModeType.WRITE are t
+ * he following.
+ *
+ * If transaction T1 calls lock(entity, LockModeType.READ) on a versioned object, the entity
+ * manager must ensure that neither of the following phenomena can occur:
+ *
+ * * P1 (Dirty read): Transaction T1 modifies a row. Another transaction T2 then reads
+ * that row and obtains the modified value, before T1 has committed or rolled back.
+ * Transaction T2 eventually commits successfully; it does not matter whether T1 commits or rolls
+ * back and whether it does so before or after T2 commits.
+ *
+ * * P2 (Non-repeatable read): Transaction T1 reads a row. Another transaction T2 then modifies
+ * or deletes that row, before T1 has committed. Both transactions eventually commit successfully.
+ *
+ * Lock modes must always prevent the phenomena P1 and P2.
+ * In addition, calling lock(entity, LockModeType.WRITE) on a versioned object,
+ * will also force an update (increment) to the entity's version column.
+ *
+ * The persistence implementation is not required to support calling EntityManager.lock()
+ * on a non-versioned object. When it cannot support a such lock call, it must
+ * throw the PersistenceException.
+ *
  * @author Emmanuel Bernard
  */
 public enum LockModeType {
+	/**
+	 * Read lock
+	 */
 	READ,
+	/**
+	 * Write lock
+	 */
 	WRITE
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ManyToMany.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ManyToMany.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ManyToMany.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -10,12 +10,42 @@
 import static javax.persistence.FetchType.*;
 
 /**
+ * Defines a many-valued association with many-to-many multiplicity. If the Collection is
+ * defined using generics to specify the element type, the associated target entity class
+ * does not need to be specified; otherwise it must be specified.
+ *
+ * Every many-to-many association has two sides, the owning side and the non-owning, or inverse,
+ * side. The join table is specified on the owning side. If the association is bidirectional,
+ * either side may be designated as the owning side.
+ *
+ * The same annotation elements for the OneToMany annotation apply to the ManyToMany annotation.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)
 public @interface ManyToMany {
+	/**
+	 * The entity class that is the target of the association. Optional only if the
+	 * collection property is defined using Java generics. Must be specified otherwise.
+	 *
+	 * Defaults to the parameterized type of the collection when defined using generics.
+	 */
 	Class targetEntity() default void.class;
+	/**
+	 * The operations that must be cascaded to the target of the association.
+	 *
+	 * Defaults to no operations being cascaded.
+	 */
 	CascadeType[] cascade() default {};
+	/**
+	 * Whether the association should be lazily loaded or must be eagerly fetched.
+	 * The EAGER strategy is a requirement on the persistenceprovider runtime that
+	 * the associatedentities must be eagerly fetched. The LAZY strategy is a hint
+	 * to the persistence provider runtime.
+	 */
 	FetchType fetch() default LAZY;
+	/**
+	 * The field that owns the relationship. Required unless the relationship is unidirectional.
+	 */
 	String mappedBy() default "";
 }
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ManyToOne.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ManyToOne.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/ManyToOne.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -10,12 +10,35 @@
 import static javax.persistence.FetchType.*;
 
 /**
+ * This annotation defines a single-valued association to another entity class that has
+ * many-to-one multiplicity. It is not normally necessary to specify the target entity
+ * explicitly since it can usually be inferred from the type of the object being referenced.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)
 public @interface ManyToOne {
+	/**
+	 * The entity class that is the target of the association.
+	 *
+	 * Defaults to the type of the field or property that stores the association
+	 */
 	Class targetEntity() default void.class;
+	/**
+	 * The operations that must be cascaded to the target of the association.
+	 *
+	 * By default no operations are cascaded.
+	 */
 	CascadeType[] cascade() default {};
+	/**
+	 * Whether the association should be lazily loaded or must be eagerly fetched.
+	 * The EAGER strategy is a requirement on the persistence provider runtime that
+	 * the associated entity must be eagerly fetched. The LAZY strategy is a hint to
+	 * the persistence provider runtime.
+	 */
 	FetchType fetch() default EAGER;
+	/**
+	 * Whether the association is optional. If set to false then a non-null relationship must always exist.
+	 */
 	boolean optional() default true;
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/MapKey.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/MapKey.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/MapKey.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -7,9 +7,19 @@
 import java.lang.annotation.Retention;
 
 /**
+ * Is used to specify the map key for associations of type Map.
+ * If a persistent field or property other than the primary key is used as a map key then it
+ * is expected to have a uniqueness constraint associated with it.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)
 public @interface MapKey {
-	String name() default "";  // name of persistent field or property of map key
+	/**
+	 * The name of the persistent field or property of the associated entity that is used as the map key.
+	 * If the name element is not specified, the primary key of the associated entity is used as the map key.
+	 * If the primary key is a composite primary key and is mapped as IdClass, an instance of the primary key
+	 * class is used as the key.
+	 */
+	String name() default "";
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/MappedSuperclass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/MappedSuperclass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/MappedSuperclass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,6 +9,16 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * Designates a class whose mapping information is applied to the entities that inherit
+ * from it. A mapped superclass has no separate table defined for it.
+ *
+ * A class designated with the MappedSuperclass annotation can be mapped in the same way as
+ * an entity except that the mappings will apply only to its subclasses since no table exists
+ * for the mapped superclass itself. When applied to the subclasses the inherited mappings will
+ * apply in the context of the subclass tables. Mapping information may be overridden in such
+ * subclasses by using the AttributeOverride and AssociationOverride annotations or corresponding *
+ * XML elements.
+ *  
  * @author Emmanuel Bernard
  */
 @Target(TYPE) @Retention(RUNTIME)

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedNativeQueries.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedNativeQueries.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedNativeQueries.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,17 +1,21 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
-import static java.lang.annotation.ElementType.PACKAGE;
 import static java.lang.annotation.ElementType.TYPE;
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
 
 /**
+ * Is used to specify an array of native SQL named queries. Query names are scoped to the persistence unit
+ *
  * @author Emmanuel Bernard
  */
- at Target({TYPE, PACKAGE}) @Retention(RUNTIME)
+ at Target({TYPE}) @Retention(RUNTIME)
 public @interface NamedNativeQueries {
+	/**
+	 * Array of native SQL named queries
+	 */
 	NamedNativeQuery [] value ();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedNativeQuery.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedNativeQuery.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedNativeQuery.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import static java.lang.annotation.ElementType.*;
@@ -8,19 +8,32 @@
 import java.lang.annotation.Target;
 
 /**
+ * Is used to specify a native SQL named query. Query names are scoped to the persistence unit.
+ *
  * @author Emmanuel Bernard
  */
-//TODO remove the package target
- at Target({TYPE, PACKAGE})
+ at Target({TYPE})
 @Retention(RUNTIME)
 public @interface NamedNativeQuery {
+	/**
+	 * Is used to refer to the query when using the EntityManager methods that create query objects
+	 */
 	String name();
-
+	/**
+	 * The SQL query string
+	 */
 	String query();
 
+	/**
+	 * Vendor-specific query hints
+	 */
 	QueryHint[] hints() default {};
-
+	/**
+	 * The class of the result
+	 */
 	Class resultClass() default void.class;
-
+	/**
+	 * The name of a SqlResultSetMapping, as defined in metadata
+	 */
 	String resultSetMapping() default ""; // name of SQLResultSetMapping
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedQueries.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedQueries.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedQueries.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,18 +1,21 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
-import static java.lang.annotation.ElementType.PACKAGE;
 import static java.lang.annotation.ElementType.TYPE;
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
 
 /**
+ * Specifies an array of named Java Persistence query language queries. Query names are scoped to the persistence unit.
+ *
  * @author Emmanuel Bernard
  */
-//TODO remove PACKAGE target
- at Target({TYPE, PACKAGE}) @Retention(RUNTIME)
+ at Target({TYPE}) @Retention(RUNTIME)
 public @interface NamedQueries {
+	/**
+	 * An array of named Java Persistence query language queries.
+	 */
 	NamedQuery [] value ();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedQuery.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedQuery.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NamedQuery.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -8,12 +8,24 @@
 import static java.lang.annotation.ElementType.*;
 
 /**
+ * Is used to specify a named query in the Java Persistence query language, which is a static
+ * query expressed in metadata. Query names are scoped to the persistence unit.
+ *
  * @author Emmanuel Bernard
  */
 //TODO remove the mackage target
- at Target({TYPE, PACKAGE}) @Retention(RUNTIME)
+ at Target({TYPE}) @Retention(RUNTIME)
 public @interface NamedQuery {
+	/**
+	 * Refers to the query when using the EntityManager methods that create query objects.
+	 */
 	String name();
+	/**
+	 * The query string in the Java Persistence query language
+	 */
 	String query();
+	/**
+	 * Vendor-specific query hints
+	 */
 	QueryHint[] hints() default {};
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NoResultException.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NoResultException.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NoResultException.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,25 +2,26 @@
 package javax.persistence;
 
 /**
- * Expected an entity result, but none found.
+ * Thrown by the persistence provider when getSingleResult() is executed on a query and there is no result to return.
+ * This exception will not cause the current transaction, if one is active, to be marked for roll back.
  * 
  * @author Emmanuel Bernard
  */
 public class NoResultException extends PersistenceException {
 
+	/**
+	 * Constructs a new NoResultException exception with null as its detail message
+	 */
 	public NoResultException() {
 		super();
 	}
 
-	public NoResultException(String message, Throwable cause) {
-		super( message, cause );
-	}
-
+	/**
+	 * Constructs a new NoResultException exception with the specified detail message.
+	 * 
+	 * @param message
+	 */
 	public NoResultException(String message) {
 		super( message );
 	}
-
-	public NoResultException(Throwable cause) {
-		super( cause );
-	}
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NonUniqueResultException.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NonUniqueResultException.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/NonUniqueResultException.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,24 +2,28 @@
 package javax.persistence;
 
 /**
+ * Thrown by the persistence provider when getSingleResult() is executed on a query and there is more than
+ * one result from the query. This exception will not cause the current transaction, if one is active, to be
+ * marked for roll back.
+ *
  * @author Gavin King
  */
 public class NonUniqueResultException extends PersistenceException {
 
+	/**
+	 * Constructs a new NonUniqueResultException exception with null as its detail message
+	 */
 	public NonUniqueResultException() {
 		super();
 	}
 
+	/**
+	 * Constructs a new NonUniqueResultException exception with the specified detail message
+	 * 
+	 * @param message
+	 */
 	public NonUniqueResultException(String message) {
 		super( message );
 	}
 
-	public NonUniqueResultException(String message, Throwable cause) {
-		super( message, cause );
-	}
-
-	public NonUniqueResultException(Throwable cause) {
-		super( cause );
-	}
-
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OneToMany.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OneToMany.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OneToMany.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -10,12 +10,38 @@
 import static javax.persistence.FetchType.*;
 
 /**
+ * Defines a many-valued association with one-to-many multiplicity.
+ *
+ * If the collection is defined using generics to specify the element type,
+ * the associated target entity type need not be specified; otherwise the target
+ * entity class must be specified.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)
 public @interface OneToMany {
+	/**
+	 * The entity class that is the target of the association. Optional only if the collection
+	 * property is defined using Java generics. Must be specified otherwise.
+	 *
+	 * Defaults to the parameterized type of the collection when defined using generics.
+	 */
 	Class targetEntity() default void.class;
+	/**
+	 * The operations that must be cascaded to the target of the association.
+	 *
+	 * Defaults to no operations being cascaded.
+	 */
 	CascadeType[] cascade() default {};
+	/**
+	 * Whether the association should be lazily loaded or must be eagerly fetched.
+	 * The EAGER strategy is a requirement on the persistenceprovider runtime that the
+	 * associatedentities must be eagerly fetched. The LAZY strategy is a hint to the
+	 * persistence provider runtime.
+	 */
 	FetchType fetch() default LAZY;
+	/**
+	 * The field that owns the relationship. Required unless the relationship is unidirectional.
+	 */
 	String mappedBy() default "";
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OneToOne.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OneToOne.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OneToOne.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -10,13 +10,42 @@
 import static javax.persistence.FetchType.*;
 
 /**
+ * This annotation defines a single-valued association to another entity that has
+ * one-to-one multiplicity. It is not normally necessary to specify the associated
+ * target entity explicitly since it can usually be inferred from the type of the object
+ * being referenced.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)
 public @interface OneToOne {
+	/**
+	 * The entity class that is the target of the association.
+	 *
+	 * Defaults to the type of the field or property that stores the association.
+	 */
 	Class targetEntity() default void.class;
+	/**
+	 * The operations that must be cascaded to the target of the association.
+	 *
+	 * By default no operations are cascaded.
+	 */
 	CascadeType[] cascade() default {};
+	/**
+	 * Whether the association should be lazily loaded or must be eagerly fetched.
+	 * The EAGER strategy is a requirement on the persistence provider runtime that
+	 * the associated entity must be eagerly fetched. The LAZY strategy is a hint to
+	 * the persistence provider runtime.
+	 */
 	FetchType fetch() default EAGER;
+	/**
+	 * Whether the association is optional. If set to false then a non-null relationship must
+	 * always exist.
+	 */
 	boolean optional() default true;
+	/**
+	 * The field that owns the relationship. This element is only specified on the
+	 * inverse (non-owning) side of the association.
+	 */
 	String mappedBy() default "";
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OptimisticLockException.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OptimisticLockException.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OptimisticLockException.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,13 +2,23 @@
 package javax.persistence;
 
 /**
+ * Thrown by the persistence provider when an optimistic locking conflict occurs.
+ * This exception may be thrown as part of an API call, a flush or at commit time.
+ * The current transaction, if one is active, will be marked for rollback.
+ *
  * @author Emmanuel Bernard
  */
 public class OptimisticLockException extends PersistenceException {
+	private Object entity;
+
 	public OptimisticLockException() {
 		super();
 	}
 
+	public OptimisticLockException(Object entity) {
+		this.entity = entity;
+	}
+
 	public OptimisticLockException(Throwable cause) {
 		super( cause );
 	}
@@ -20,4 +30,13 @@
 	public OptimisticLockException(String message, Throwable cause) {
 		super( message, cause );
 	}
+
+	public OptimisticLockException(String message, Throwable cause, Object entity) {
+		super( message, cause );
+		this.entity = entity;
+	}
+
+	public Object getEntity() {
+		return entity;
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OrderBy.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OrderBy.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/OrderBy.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -8,9 +8,32 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * This annotation specifies the ordering of the elements of a collection valued association at the
+ * point when the association is retrieved.
+ *
+ * The syntax of the value ordering element is an orderby_list, as follows:
+ *   <code>orderby_list::= orderby_item [,orderby_item]*
+ *  orderby_item::= property_or_field_name [ASC | DESC]</code>
+ *
+ * If ASC or DESC is not specified, ASC (ascending order) is assumed.
+ *
+ * If the ordering element is not specified, ordering by the primary key of the associated
+ * entity is assumed.
+ *
+ * The property or field name must correspond to that of a persistent property or field of the
+ * associated class. The properties or fields used in the ordering must correspond to columns
+ * for which comparison operators are supported.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)
 public @interface OrderBy {
+	/**
+	 * An orderby_list, specified as follows:
+	 * orderby_list::= orderby_item [,orderby_item]* orderby_item::= property_or_field_name [ASC | DESC]
+	 *
+	 * If ASC or DESC is not specified, ASC (ascending order) is assumed.
+	 *
+	 */
 	String value() default "";
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Persistence.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Persistence.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Persistence.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -21,12 +21,26 @@
 
 	public static String PERSISTENCE_PROVIDER = PersistenceProvider.class.getName();
 
-	protected static Set<PersistenceProvider> providers = new HashSet<PersistenceProvider>();
+	protected static final Set<PersistenceProvider> providers = new HashSet<PersistenceProvider>();
 
+	/**
+	 * Create and return an EntityManagerFactory for the named persistence unit.
+	 *
+	 * @param persistenceUnitName The name of the persistence unit
+	 * @return The factory that creates EntityManagers configured according to the specified persistence unit
+	 */
 	public static EntityManagerFactory createEntityManagerFactory(String persistenceUnitName) {
 		return createEntityManagerFactory( persistenceUnitName, null );
 	}
 
+	/**
+	 * Create and return an EntityManagerFactory for the named persistence unit using the given properties.
+	 *
+	 * @param persistenceUnitName The name of the persistence unit
+	 * @param properties Additional properties to use when creating the factory. The values of these properties override
+	 * any values that may have been configured elsewhere
+	 * @return The factory that creates EntityManagers configured according to the specified persistence unit
+	 */
 	public static EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
 		EntityManagerFactory emf = null;
 

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContext.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContext.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContext.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
@@ -12,16 +12,32 @@
 import java.lang.annotation.Target;
 
 /**
- * Comment
+ * Expresses a dependency on an EntityManager persistence context.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
  */
 @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface PersistenceContext
-{
-   String name() default "";
-   String unitName() default "";
-   PersistenceContextType type() default PersistenceContextType.TRANSACTION;
+public @interface PersistenceContext {
+	/**
+	 * The name by which the entity manager is to be accessed in the environment referencing context,
+	 * and is not needed when dependency injection is used.
+	 */
+	String name() default "";
+	/**
+	 * The name of the persistence unit. If the unitName element is specified, the persistence unit
+	 * for the entity manager that is accessible in JNDI must have the same name.
+	 */
+	String unitName() default "";
+	/**
+	 * Used to specify properties for the container or persistence provider. Vendor specific
+	 * properties may be included in this set of properties. Properties that are not
+	 * recognized by a vendor are ignored.
+	 */
+	PersistenceProperty[] properties() default {};
+	/**
+	 * Specifies whether this is a transaction-scoped persistence context or
+	 * an extended persistence context.
+	 */
+	PersistenceContextType type() default PersistenceContextType.TRANSACTION;
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContextType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContextType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContextType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,7 +1,18 @@
 //$Id$
 package javax.persistence;
 
+/**
+ * Specifies whether a transaction-scoped or extended persistence context is to be used in
+ * PersistenceContext. If the type element is not specified, a transaction-scoped persistence
+ * context is used.
+ */
 public enum PersistenceContextType {
-	  TRANSACTION,
-	  EXTENDED
+	/**
+	 * Transaction-scoped persistence context
+	 */
+	TRANSACTION,
+	/**
+	 * Extended persistence context
+	 */
+	EXTENDED
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContexts.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContexts.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceContexts.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
@@ -12,14 +12,16 @@
 import java.lang.annotation.Target;
 
 /**
- * Comment
+ * Declares one or more PersistenceContext annotations. It is used to express a dependency on
+ * container-managed entity manager persistence contexts.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
  */
- at Target({ ElementType.TYPE })
+ at Target({ElementType.TYPE})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface PersistenceContexts
-{
-   PersistenceContext[] value();
+public @interface PersistenceContexts {
+	/**
+	 * One or more persistence context
+	 */
+	PersistenceContext[] value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceException.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceException.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceException.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss, Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
@@ -7,29 +7,44 @@
 package javax.persistence;
 
 /**
- * Comment
+ * Thrown by the persistence provider when a problem occurs. All instances of PersistenceException
+ * except for instances of NoResultException and NonUniqueResultException will cause the current
+ * transaction, if one is active, to be marked for rollback.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
  */
-public class PersistenceException extends RuntimeException
-{
-   public PersistenceException()
-   {
-   }
+public class PersistenceException extends RuntimeException {
+	/**
+	 * Constructs a new PersistenceException exception with null as its detail message.
+	 */
+	public PersistenceException() {
+	}
 
-   public PersistenceException(String message)
-   {
-      super(message);
-   }
+	/**
+	 * Constructs a new PersistenceException exception with the specified detail message.
+	 *
+	 * @param message the detail message
+	 */
+	public PersistenceException(String message) {
+		super( message );
+	}
 
-   public PersistenceException(String message, Throwable cause)
-   {
-      super(message, cause);
-   }
+	/**
+	 * Constructs a new PersistenceException exception with the specified detail message and cause
+	 *
+	 * @param message the detail message
+	 * @param cause the cause
+	 */
+	public PersistenceException(String message, Throwable cause) {
+		super( message, cause );
+	}
 
-   public PersistenceException(Throwable cause)
-   {
-      super(cause);
-   }
+	/**
+	 * Constructs a new PersistenceException exception with the specified cause
+	 *
+	 * @param cause the cause
+	 */
+	public PersistenceException(Throwable cause) {
+		super( cause );
+	}
 }

Copied: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceProperty.java (from rev 10565, trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceProperty.java)

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceUnit.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceUnit.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceUnit.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
@@ -12,15 +12,22 @@
 import java.lang.annotation.Target;
 
 /**
- * Comment
+ * Expresses a dependency on an EntityManagerFactory.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
  */
 @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface PersistenceUnit
-{
-   String name() default "";
-   String unitName() default "";
+public @interface PersistenceUnit {
+	/**
+	 * The name by which the entity manager factory is to be accessed in the environment
+	 * referencing context, and is not needed when dependency injection is used.
+	 */
+	String name() default "";
+	/**
+	 * The name of the persistence unit as defined in the persistence.xml file. If specified, the
+	 * persistence unit for the entity manager factory that is accessible in JNDI must have the
+	 * same name.
+	 */
+	String unitName() default "";
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceUnits.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceUnits.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PersistenceUnits.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
@@ -10,17 +10,17 @@
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
-import javax.persistence.PersistenceUnit;
 
 /**
- * Comment
+ * Declares one or more PersistenceUnit annotations
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
  */
 @Target({ElementType.TYPE})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface PersistenceUnits
-{
-   PersistenceUnit[] value();
+public @interface PersistenceUnits {
+	/**
+	 * One or more PersistenceUnit annotations
+	 */
+	PersistenceUnit[] value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostLoad.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostLoad.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostLoad.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
@@ -13,12 +13,12 @@
 
 
 /**
- * comment
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied to
+ * methods of an entity class, a mapped superclass, or a callback listener class.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  */
 @Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface PostLoad
-{
+public @interface PostLoad {
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostPersist.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostPersist.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostPersist.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,10 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
  */
+
 package javax.persistence;
 
 import java.lang.annotation.ElementType;
@@ -13,12 +14,12 @@
 
 
 /**
- * comment
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be
+ * applied to methods of an entity class, a mapped superclass, or a callback listener class.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  */
 @Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface PostPersist
-{
+public @interface PostPersist {
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostRemove.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostRemove.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostRemove.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,10 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
  */
+
 package javax.persistence;
 
 import java.lang.annotation.ElementType;
@@ -13,12 +14,12 @@
 
 
 /**
- * comment
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied
+ * to methods of an entity class, a mapped superclass, or a callback listener class.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  */
 @Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface PostRemove
-{
+public @interface PostRemove {
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostUpdate.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostUpdate.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PostUpdate.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,10 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
  */
+
 package javax.persistence;
 
 import java.lang.annotation.ElementType;
@@ -13,12 +14,12 @@
 
 
 /**
- * comment
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied to
+ * methods of an entity class, a mapped superclass, or a callback listener class.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  */
 @Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface PostUpdate
-{
+public @interface PostUpdate {
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrePersist.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrePersist.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrePersist.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,10 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
  */
+
 package javax.persistence;
 
 import java.lang.annotation.ElementType;
@@ -13,12 +14,12 @@
 
 
 /**
- * comment
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied
+ * to methods of an entity class, a mapped superclass, or a callback listener class.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  */
 @Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface PrePersist
-{
+public @interface PrePersist {
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PreRemove.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PreRemove.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PreRemove.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,10 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
  */
+
 package javax.persistence;
 
 import java.lang.annotation.ElementType;
@@ -13,12 +14,12 @@
 
 
 /**
- * comment
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied
+ * to methods of an entity class, a mapped superclass, or a callback listener class.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  */
 @Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface PreRemove
-{
+public @interface PreRemove {
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PreUpdate.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PreUpdate.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PreUpdate.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,10 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
  */
+
 package javax.persistence;
 
 import java.lang.annotation.ElementType;
@@ -13,12 +14,12 @@
 
 
 /**
- * comment
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be
+ * applied to methods of an entity class, a mapped superclass, or a callback listener class.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  */
 @Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface PreUpdate
-{
+public @interface PreUpdate {
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrimaryKeyJoinColumn.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrimaryKeyJoinColumn.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrimaryKeyJoinColumn.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,11 +9,45 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * This annotation specifies a primary key column that is used as a foreign key to join to another
+ * table.
+ *
+ * It is used to join the primary table of an entity subclass in the JOINED mapping strategy to
+ * the primary table of its superclass; it is used within a SecondaryTable annotation to join a
+ * secondary table to a primary table; and it may be used in a OneToOne mapping in which the
+ * primary key of the referencing entity is used as a foreign key to the referenced entity.
+ *
+ * If no PrimaryKeyJoinColumn annotation is specified for a subclass in the JOINED mapping
+ * strategy, the foreign key columns are assumed to have the same names as the primary key
+ * columns of the primary table of the superclass
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
 public @interface PrimaryKeyJoinColumn {
+	/**
+	 * The name of the primary key column of the current table.
+	 *
+	 * Defaults to the same name as the primary key column of the primary table of the
+	 * superclass (JOINED mapping strategy); the same name as the primary key column of
+	 * the primary table (SecondaryTable mapping); or the same name as the primary key
+	 * column for the table for the referencing entity (OneToOne mapping)
+	 */
 	String name() default "";
+	/**
+	 * The name of the primary key column of the table being joined to.
+	 *
+	 * Defaults to the same name as the primary key column of the primary table of the
+	 * superclass (JOINED mapping strategy); the same name as the primary key column of the
+	 * primary table (SecondaryTable mapping); or the same name as the primary key column for
+	 * the table for the referencing entity (OneToOne mapping)
+	 */
 	String referencedColumnName() default "";
+	/**
+	 * The SQL fragment that is used when generating the DDL for the column. This should not be
+	 * specified for a OneToOne primary key association.
+	 *
+	 * Defaults to the generated SQL to create a column of the inferred type.
+	 */
 	String columnDefinition() default "";
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrimaryKeyJoinColumns.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrimaryKeyJoinColumns.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/PrimaryKeyJoinColumns.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,9 +9,14 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * This annotation groups PrimaryKeyJoinColumn annotations. It is used to map composite foreign keys.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
 public @interface PrimaryKeyJoinColumns {
-	PrimaryKeyJoinColumn[] value() default {};
+	/**
+	 * One or more PrimaryKeyJoinColumn annotations
+	 */
+	PrimaryKeyJoinColumn[] value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Query.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Query.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Query.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -14,6 +14,7 @@
 	 * Execute the query and return the query results as a List.
 	 *
 	 * @return a list of the results
+	 * @throws IllegalStateException f called for a Java Persistence query language UPDATE or DELETE statement
 	 */
 	public List getResultList();
 
@@ -22,7 +23,8 @@
 	 *
 	 * @return the result
 	 * @throws EntityNotFoundException  if there is no result
-	 * @throws NonUniqueResultException if more than one result
+	 * @throws NonUniqueResultException if more than one resul
+	 * @throws IllegalStateException f called for a Java Persistence query language UPDATE or DELETE statement
 	 */
 	public Object getSingleResult();
 
@@ -30,6 +32,8 @@
 	 * Execute an update or delete statement.
 	 *
 	 * @return the number of entities updated or deleted
+	 * @throws IllegalStateException if called for a Java Persistence query language SELECT statement
+	 * @throws TransactionRequiredException if there is no transaction
 	 */
 	public int executeUpdate();
 
@@ -68,7 +72,7 @@
 	 * @param name  the parameter name
 	 * @param value
 	 * @return the same query instance
-	 * @throws IllegalArgumentException if parameter name does not* correspond to parameter in query
+	 * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
 	 *                                  string or argument is of incorrect type
 	 */
 	public Query setParameter(String name, Object value);

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/QueryHint.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/QueryHint.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/QueryHint.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -6,12 +6,20 @@
 import java.lang.annotation.Target;
 
 /**
+ * An implementation-specific Query hint
+ *
  * @author Emmanuel Bernard
  */
 @Target({})
 @Retention(RUNTIME)
 public @interface QueryHint {
+	/**
+	 * Name of the hint
+	 */
 	String name();
 
+	/**
+	 * Value of the hint
+	 */
 	String value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/RollbackException.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/RollbackException.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/RollbackException.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,23 +2,42 @@
 package javax.persistence;
 
 /**
- * Exception occurs while commiting the transaction
+ * Thrown by the persistence provider when the EntityTransaction.commit() fails
  *
  * @author Emmanuel Bernard
  */
 public class RollbackException extends PersistenceException {
+	/**
+	 * Constructs a new RollbackException exception with null as its detail message
+	 */
 	public RollbackException() {
 		super();
 	}
 
+	/**
+	 * Constructs a new RollbackException exception with the specified cause
+	 *
+	 * @param cause The detail cause
+	 */
 	public RollbackException(Throwable cause) {
 		super( cause );
 	}
 
+	/**
+	 * Constructs a new RollbackException exception with the specified detail message
+	 *
+	 * @param message The detail message
+	 */
 	public RollbackException(String message) {
 		super( message );
 	}
 
+	/**
+	 * Constructs a new RollbackException exception with the specified detail message and cause
+	 *
+	 * @param message The detail message
+	 * @param cause The detail cause
+	 */
 	public RollbackException(String message, Throwable cause) {
 		super( message, cause );
 	}

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SecondaryTable.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SecondaryTable.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SecondaryTable.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,13 +9,45 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * This annotation is used to specify a secondary table for the annotated entity class. Specifying
+ * one or more secondary tables indicates that the data for the entity class is stored across multiple
+ * tables.
+ *
+ * If no SecondaryTable annotation is specified, it is assumed that all persistent fields or properties
+ * of the entity are mapped to the primary table. If no primary key join columns are specified, the
+ * join columns are assumed to reference the primary key columns of the primary table, and have the
+ * same names and types as the referenced primary key columns of the primary table.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE}) @Retention(RUNTIME)
 public @interface SecondaryTable {
+	/**
+	 * The name of the table
+	 */
 	String name();
+	/**
+	 * The catalog of the table
+	 */
 	String catalog() default "";
+	/**
+	 * The schema of the table
+	 */
 	String schema() default "";
+	/**
+	 * The columns that are used to join with the primary table.
+	 *
+	 * Defaults to the column(s) of the same name(s) as the primary key column(s)
+	 * in the primary table
+	 */
 	PrimaryKeyJoinColumn[] pkJoinColumns() default {};
+	/**
+	 * Unique constraints that are to be placed on the table. These are typically only used if
+	 * table generation is in effect. These constraints apply in addition to any constraints
+	 * specified by the Column and JoinColumn annotations and constraints entailed by primary
+	 * key mappings.
+	 *
+	 * Defaults to no additional constraints.
+	 */
 	UniqueConstraint[] uniqueConstraints() default {};
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SecondaryTables.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SecondaryTables.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SecondaryTables.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -8,9 +8,14 @@
 import static java.lang.annotation.ElementType.*;
 import static java.lang.annotation.RetentionPolicy.*;
 /**
+ * This annotation is used to specify multiple secondary tables for an entity.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE}) @Retention(RUNTIME)
 public @interface SecondaryTables {
-	SecondaryTable[] value() default {};
+	/**
+	 * The secondary tables for an entity.
+	 */
+	SecondaryTable[] value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SequenceGenerator.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SequenceGenerator.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SequenceGenerator.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,13 +9,30 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * This annotation defines a primary key generator that may be referenced by name when a generator
+ * element is specified for the GeneratedValue annotation. A sequence generator may be specified on
+ * the entity class or on the primary key field or property. The scope of the generator name is global
+ * to the persistence unit (across all generator types).
+ *
  * @author Emmanuel Bernard
  */
-//TODO remove Package eventually
- at Target({PACKAGE, TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+ at Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
 public @interface SequenceGenerator {
-    String name();
-    String sequenceName() default "";
-    int initialValue() default 1;
-    int allocationSize() default 50;
+	/**
+	 * A unique generator name that can be referenced by one or more classes to be the generator for primary key values
+	 */
+	String name();
+	/**
+	 * The name of the database sequence object from which to obtain primary key values
+	 * Defaults to a provider-chosen value
+	 */
+	String sequenceName() default "";
+	/**
+	 * The value from which the sequence object is to start generating
+	 */
+	int initialValue() default 1;
+	/**
+	 * The amount to increment by when allocating sequence numbers from the sequence
+	 */
+	int allocationSize() default 50;
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SqlResultSetMapping.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SqlResultSetMapping.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SqlResultSetMapping.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Target;
@@ -8,12 +8,22 @@
 import java.lang.annotation.RetentionPolicy;
 
 /**
+ * This annotation is used to specify the mapping of the result of a native SQL query
+ *
  * @author Emmanuel Bernard
  */
-//TODO remove the package target
- at Target({ElementType.PACKAGE, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME)
 public @interface SqlResultSetMapping {
+	/**
+	 * The name given to the result set mapping, and used to refer to it in the methods of the Query API
+	 */
 	String name();
+	/**
+	 * Specifies the result set mapping to entities
+	 */
 	EntityResult[] entities() default {};
+	/**
+	 * Specifies the result set mapping to scalar values
+	 */
 	ColumnResult[] columns() default {};
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SqlResultSetMappings.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SqlResultSetMappings.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/SqlResultSetMappings.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -9,10 +9,11 @@
 import java.lang.annotation.RetentionPolicy;
 
 /**
+ * This annotation is used to define one or more SqlResultSetMapping
+ *
  * @author Emmanuel Bernard
  */
-//TODO remove Package target
- at Target({ElementType.PACKAGE, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME)
 public @interface SqlResultSetMappings {
 	SqlResultSetMapping[] value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Table.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Table.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Table.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,12 +9,40 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * This annotation specifies the primary table for the annotated entity. Additional
+ * tables may be specified using SecondaryTable  or SecondaryTables annotation.
+ *
+ * If no Table annotation is specified for an entity class, the default values apply.
+ *
  * @author Emmanuel Bernard
  */
 @Target({TYPE}) @Retention(RUNTIME)
 public @interface Table {
+	/**
+	 * The name of the table.
+	 *
+	 * Defaults to the entity name.
+	 */
 	String name() default "";
+	/**
+	 * The catalog of the table.
+	 *
+	 * Defaults to the default catalog.
+	 */
 	String catalog() default "";
+	/**
+	 * The schema of the table.
+	 *
+	 * Defaults to the default schema for user.
+	 */
 	String schema() default "";
+	/**
+	 * Unique constraints that are to be placed on the table. These are only used if table
+	 * generation is in effect. These constraints apply in addition to any constraints
+	 * specified by the Column and JoinColumn annotations and constraints entailed by
+	 * primary key mappings.
+	 *
+	 * Defaults to no additional constraints.
+	 */
 	UniqueConstraint[] uniqueConstraints() default {};
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TableGenerator.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TableGenerator.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TableGenerator.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import static java.lang.annotation.ElementType.*;
@@ -8,30 +8,60 @@
 import java.lang.annotation.Target;
 
 /**
+ * This annotation defines a primary key generator that may be referenced by name when a generator
+ * element is specified for the GeneratedValue annotation. A table generator may be specified on the
+ * entity class or on the primary key field or property. The scope of the generator name is global to
+ * the persistence unit (across all generator types).
+ *
  * @author Emmanuel Bernard
  */
-//TODO remove Package eventually
- at Target({PACKAGE, TYPE, METHOD, FIELD})
+ at Target({TYPE, METHOD, FIELD})
 @Retention(RUNTIME)
 public @interface TableGenerator {
-
+	/**
+	 * A unique generator name that can be referenced by one or more classes to be the generator for id values
+	 */
 	String name();
-
+	/**
+	 * Name of table that stores the generated id values. Defaults to a name chosen by persistence provider.
+	 */
 	String table() default "";
-
+	/**
+	 * The catalog of the table
+	 * Defaults to the default catalog
+	 */
 	String catalog() default "";
-
+	/**
+	 * The schema of the table
+	 * Defaults to the default schema for user
+	 */
 	String schema() default "";
-
+	/**
+	 * Name of the primary key column in the table
+	 * Defaults to a provider-chosen name
+	 */
 	String pkColumnName() default "";
-
+	/**
+	 * Name of the column that stores the last value generated
+	 * Defaults to a provider-chosen name
+	 */
 	String valueColumnName() default "";
-
+	/**
+	 * The primary key value in the generator table that distinguishes this set of generated values from others that may be stored in the table
+	 * Defaults to a provider-chosen value to store in the primary key column of the generator table
+	 */
 	String pkColumnValue() default "";
-
+	/**
+	 * The initial value to be used when allocating id numbers from the generator
+	 */
 	int initialValue() default 0;
-
+	/**
+	 * The amount to increment by when allocating id numbers from the generator
+	 */
 	int allocationSize() default 50;
-
+	/**
+	 * Unique constraints that are to be placed on the table. These are only used if table generation is in effect. These constraints apply in addition to primary key constraints
+	 * Defaults to no additional constraints
+	 */
 	UniqueConstraint[] uniqueConstraints() default {};
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Temporal.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Temporal.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Temporal.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import static java.lang.annotation.ElementType.FIELD;
@@ -9,10 +9,18 @@
 import java.lang.annotation.Target;
 
 /**
+ * This annotation must be specified for persistent fields or properties of type Date and Calendar.
+ * It may only be specified for fields or properties of these types.
+ *
+ * The Temporal annotation may be used in conjunction with the Basic annotation.
+ *
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD})
 @Retention(RUNTIME)
 public @interface Temporal {
+	/**
+	 * The type used in mapping java.util.Date or java.util.Calendar
+	 */
 	TemporalType value();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TemporalType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TemporalType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TemporalType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,21 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
+/**
+ * Type used to indicate a specific mapping of Date or Calendar.
+ */
 public enum TemporalType {
-	DATE, // java.sql.Date
-	TIME, // java.sql.Time
-	TIMESTAMP // java.sql.Timestamp
+	/**
+	 * Map as java.sql.Date
+	 */
+	DATE,
+	/**
+	 * Map as java.sql.Time
+	 */
+	TIME,
+	/**
+	 * Map as java.sql.Timestamp
+	 */
+	TIMESTAMP
 }
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TransactionRequiredException.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TransactionRequiredException.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/TransactionRequiredException.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,24 +2,25 @@
 package javax.persistence;
 
 /**
+ * Thrown by the persistence provider when a transaction is required but is not active.
  * @author Gavin King
  */
 public class TransactionRequiredException extends PersistenceException {
 
+	/**
+	 * Constructs a new TransactionRequiredException exception with null as its detail message
+	 */
 	public TransactionRequiredException() {
 		super();
 	}
 
+	/**
+	 * Constructs a new TransactionRequiredException exception with the specified detail message
+	 * 
+	 * @param message
+	 */
 	public TransactionRequiredException(String message) {
 		super( message );
 	}
 
-	public TransactionRequiredException(String message, Throwable cause) {
-		super( message, cause );
-	}
-
-	public TransactionRequiredException(Throwable cause) {
-		super( cause );
-	}
-
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Transient.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Transient.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Transient.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,6 +9,9 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * This annotation specifies that the property or field is not persistent. It is used to annotate
+ * a property or field of an entity class, mapped superclass, or embeddable class.
+ * 
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/UniqueConstraint.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/UniqueConstraint.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/UniqueConstraint.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,16 +1,21 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
 
-import static java.lang.annotation.RetentionPolicy.*;
-
 /**
+ * This annotation is used to specify that a unique constraint is to be included in the generated DDL
+ * for a primary or secondary table
+ *
  * @author Emmanuel Bernard
  */
 @Target({}) @Retention(RUNTIME)
 public @interface UniqueConstraint {
+	/**
+	 * An array of the column names that make up the constraint
+	 */
 	String[] columnNames();
 }

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Version.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Version.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/Version.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 //$Id$
-//EJB3 Specification Copyright 2004, 2005 Sun Microsystems, Inc.
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence;
 
 import java.lang.annotation.Retention;
@@ -9,6 +9,19 @@
 import static java.lang.annotation.RetentionPolicy.*;
 
 /**
+ * This annotation specifies the version field or property of an entity class that serves as its
+ * optimistic lock value. The version is used to ensure integrity when performing the merge
+ * operation and for optimistic concurrency control.
+ *
+ * Only a single Version property or field should be used per class; applications that use more
+ * than one Version property or field will not be portable.
+ *
+ * The Version property should be mapped to the primary table for the entity class; applications
+ * that map the Version property to a table other than the primary table will not be portable.
+ *
+ * The following types are supported for version properties: int, Integer, short, Short, long,
+ * Long, Timestamp.
+ *  
  * @author Emmanuel Bernard
  */
 @Target({METHOD, FIELD}) @Retention(RUNTIME)

Copied: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/package-info.java (from rev 10565, trunk/HibernateExt/ejb-api/src/javax/persistence/package-info.java)

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/ClassTransformer.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/ClassTransformer.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/ClassTransformer.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,24 +1,5 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+//$Id$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence.spi;
 
 import java.security.ProtectionDomain;

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceProvider.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceProvider.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceProvider.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,4 +1,5 @@
-// $Id$
+//$Id$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence.spi;
 
 import java.util.Map;

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitInfo.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitInfo.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitInfo.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,5 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
+//$Id$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.package javax.persistence.spi;
 package javax.persistence.spi;
 
 import java.net.URL;

Modified: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitTransactionType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitTransactionType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitTransactionType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,34 +1,20 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+//$Id$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
 package javax.persistence.spi;
 
 /**
- * Defines whether a persistence unit will be JTA managed or manged locally with EntityTransactions
+ * This enum class defines whether the entity managers created by the EntityManagerFactory will be
+ * JTA or resource-local entity managers.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
  */
-public enum PersistenceUnitTransactionType
-{
-   JTA,
-   RESOURCE_LOCAL
+public enum PersistenceUnitTransactionType {
+	/**
+	 * JTA entity manager
+	 */
+	JTA,
+	/**
+	 * Resource-local entity manager
+	 */
+	RESOURCE_LOCAL
 }

Copied: branches/Lucene_Integration/HibernateExt/ejb-api/src/javax/persistence/spi/package-info.java (from rev 10565, trunk/HibernateExt/ejb-api/src/javax/persistence/spi/package-info.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/build.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/build.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/build.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -16,7 +16,7 @@
     <!-- Name of project and version, used to create filenames -->
     <property name="Name" value="Hibernate Annotations"/>
     <property name="name" value="hibernate-annotations"/>
-    <property name="version" value="3.2.0.CR1"/>
+    <property name="version" value="3.2.0.CR3"/>
     <property name="javadoc.packagenames" value="org.hibernate.*"/>
 	<property name="jdbc.dir" value="jdbc"/>
     <property name="copy.test" value="true"/>

Modified: branches/Lucene_Integration/HibernateExt/metadata/changelog.txt
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/changelog.txt	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/changelog.txt	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,6 +1,84 @@
 Hibernate Annotations Changelog
 ===============================
 
+3.2.0.CR3 (04-10-2006)
+----------------------
+** Bug
+    * [ANN-408] - map a entity to integer map is not possible
+
+
+** Improvement
+    * [ANN-346] - Introduce @FilterJoinTable to complete @Filter on association involving a join table
+    * [ANN-447] - Introduce @WhereJoinTable to complete @Where on association involving a join table
+
+** New Feature
+    * [ANN-443] - Define a hibernate.validator.interpolator_class
+
+
+3.2.0.CR2 (16-09-2006)
+----------------------
+** Bug
+    * [ANN-181] - Do not fail on unbound attributes marked as @Type
+    * [ANN-243] - @MapKey doesn't properly refer to column name mapped to property (quoted column)
+    * [ANN-345] - EJB3NamingStrategy should be Serializable
+    * [ANN-359] - @MappedSuperclass overriding fails on EJB3 DD
+    * [ANN-362] - Specification of table @Table name with quotes using backticks fails with @OneToMany mapping
+    * [ANN-368] - Keywords first letter is not decapilalized
+    * [ANN-369] - @CollectionOfElements on a Map uses reserved word "key" as column name
+    * [ANN-370] - Lucene updates are not thread safe
+    * [ANN-375] - @Email validator failed a valid email address
+    * [ANN-379] -  Map<Entity, Entity> fails due to unique constraint on map-key column
+    * [ANN-382] - Id involving many to one may fail depending on the entity process ordering
+    * [ANN-393] - Documentation errors in Many-toMany Annotation explanation
+    * [ANN-405] - JPA XML overriding wrong when default schema and *-to-one association
+    * [ANN-409] - Enum constants in HQL leads to ClassCastException
+    * [ANN-411] - @Generated(INSERT) properties does not update columns
+    * [ANN-412] - Generator definition (@Table,  @Generic,  @Sequence) no longer taken into account at field level
+    * [ANN-414] - Map, OneToMany, join table or @ManyToMany does not work on MySQL and on composite keys
+    * [ANN-415] - <named-native-query result-class leads to CCE
+    * [ANN-416] - Mapping of inheritance with several generic superclasses fails
+    * [ANN-421] - Unable to map no packaged classes when JPA XML is used
+    * [ANN-423] - @Min/@Max broken with BigInteger/BigDecimal
+    * [ANN-424] - column overriding fails on composite elements when defined at the entity level
+    * [ANN-426] - Validator keep a JavaXFactory in a static variable creating memleaks on redeployement
+    * [ANN-427] - throw "java.lang.IllegalStateException: Property parent has an unbound type and no explicit target entity." on generic type
+
+
+** Improvement
+    * [ANN-7] - Document usage of @IndexColumn in one-to-many with indexed collection
+    * [ANN-36] - @ForceDiscriminator (Serg Prasolov)
+    * [ANN-39] - @CollectionId for idbags
+    * [ANN-47] - Allow to set an enum parameter on a query
+    * [ANN-261] - Allow specifying foreign key constraint name using annotations (inspired by David Hay)
+    * [ANN-265] - Fall back to default validator message if the key is not found
+    * [ANN-343] - validator messages in brazilian portuguese
+    * [ANN-350] - Support ejb3 dd when no schema locator is defined
+    * [ANN-351] - Validator Brazilian translation
+    * [ANN-355] - Make XML overriding rules for access type smoother
+    * [ANN-356] - Clear the PC on Rollback on RESOURCE_LOCAL Transactions
+    * [ANN-371] - Abstract DocumentBuilder from the underlying Directory implementation
+    * [ANN-373] - imports are not done for the full entityname
+    * [ANN-374] - Map - OneToMany w or w/o join table creates bad sql
+    * [ANN-381] - Make possible to specify an @EmbeddedId's field in a @OneToMany's mappedBy property
+    * [ANN-397] - Incomplete AnnotationException at org.hibernate.cfg.annotations.TableBinder
+    * [ANN-399] - Class validator should not WARN on unbound properties not involved in validation
+
+** New Feature
+    * [ANN-284] - @OrderBy clash with @Formula Properties
+    * [ANN-349] - Add @FlushModeType.MANUAL
+    * [ANN-367] - Upgrade to Lucene 2.0.0 (Sylvain Vieujot)
+    * [ANN-372] - @Boost factor on document and fields
+    * [ANN-378] - Chinese translation (Xiaogang Cao)
+    * [ANN-385] - Abstract the Lucene directory implementation and allow configuration based definition
+    * [ANN-386] - Add support for RAMDirectory
+    * [ANN-419] - Support SortedMap
+    * [ANN-440] - MessageIntrospector hook introduced in HibernateValidator
+
+
+** Task
+    * [ANN-410] - Depreciate EJB 3 Package annotations
+
+
 3.2.0.CR1 (13-05-2006)
 ----------------------
 ** Bug

Modified: branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/master.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/master.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/master.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -13,7 +13,7 @@
 
     <subtitle>Reference Guide</subtitle>
 
-    <releaseinfo>3.2.0 CR1</releaseinfo>
+    <releaseinfo>3.2.0 CR3</releaseinfo>
 
     <mediaobject>
       <imageobject>
@@ -24,7 +24,7 @@
 
   <toc></toc>
 
-  <preface>
+  <preface id="preface" revision="1">
     <title>Preface</title>
 
     <para>Hibernate, like all other object/relational mapping tools, requires
@@ -53,24 +53,24 @@
     your project. You can at all times fall back to Hibernate native APIs, or
     if required, even to native JDBC and SQL.</para>
 
-    <para>Please note that this documentation is based on a preview release of
-    the Hibernate Annotations that follows the public final draft of EJB
-    3.0/JSR-220 persistence annotations. This work is already very close to
-    the final concepts in the new specification. Our goal is to provide a
-    complete set of ORM annotations, including EJB3 standard annotations as
-    well as Hibernate3 extensions for cases not covered by the specification.
-    Eventually you will be able to create all possible mappings with
-    annotations. See the JIRA road mapsection for more information.</para>
+    <para>This release is based on the final release of the EJB 3.0 / JPA
+    specification (aka JSP-220) and support all the specification features
+    (including the optional ones). Most of the Hibernate features and
+    extensions are also available through Hibernate specific annotations
+    compared to the specification are also available. While the Hibernate
+    feature coverage is now very high, some are still missing. The eventual
+    goal is to cover all of them. See the JIRA road map section for more
+    informations.</para>
 
-    <para>The EJB3 Public final draft has change some annotations, please
-    refer to http://www.hibernate.org/371.html as a migration guide from
-    previous versions of Hibernate Annotations.</para>
+    <para>If you are moving from previous Hibernate Annotations versions,
+    please have a look at <uri>http://www.hibernate.org/371.html</uri> for a
+    migration guide.</para>
   </preface>
 
   &setup;
 
   &entity;
-  
+
   &xml-overriding;
 
   &validator;

Modified: branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/entity.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/entity.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/entity.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -9,18 +9,18 @@
     Hibernate-specific extensions.</para>
   </sect1>
 
-  <sect1 id="mapping" revision="1">
+  <sect1 id="entity-mapping" revision="2">
     <title>Mapping with EJB3 Annotations</title>
 
     <para>EJB3 entity beans are plain POJOs. Actually they represent the exact
     same concept as the Hibernate persistent entities. Their mappings are
     defined through JDK 5.0 annotations (an XML descriptor syntax for
-    overriding will be defined in the EJB3 specification, but it's not
-    finalized so far). Annotations can be split in two categories, the logical
-    mapping annotations (allowing you to describe the object model, the class
-    associations, etc.) and the physical mapping annotations (describing the
-    physical schema, tables, columns, indexes, etc). We will mix annotations
-    from both categories in the following code examples.</para>
+    overriding is defined in the EJB3 specification). Annotations can be split
+    in two categories, the logical mapping annotations (allowing you to
+    describe the object model, the class associations, etc.) and the physical
+    mapping annotations (describing the physical schema, tables, columns,
+    indexes, etc). We will mix annotations from both categories in the
+    following code examples.</para>
 
     <para>EJB3 annotations are in the <literal>javax.persistence.*</literal>
     package. Most JDK 5 compliant IDE (like Eclipse, IntelliJ IDEA and
@@ -510,7 +510,7 @@
       </sect3>
     </sect2>
 
-    <sect2 id="mapping-identifier" label=""
+    <sect2 id="entity-mapping-identifier" label=""
            xreflabel="Mapping identifier properties">
       <title>Mapping identifier properties</title>
 
@@ -565,10 +565,18 @@
       <literal>@TableGenerator</literal>. The scope of a generator can be the
       application or the class. Class-defined generators are not visible
       outside the class and can override application level generators.
-      Application level generators are defined at package level (see
-      <classname>package-info.java</classname>):</para>
+      Application level generators are defined at XML level (see <xref
+      linkend="xml-overriding" />):</para>
 
-      <programlisting>
+      <programlisting>&lt;table-generator name="EMP_GEN"
+            table="GENERATOR_TABLE"
+            pk-column-name="key"
+            value-column-name="hi"
+            pk-column-value="EMP"
+            allocation-size="20"/&gt;
+
+//and the annotation equivalent
+
 @javax.persistence.TableGenerator(
     name="EMP_GEN",
     table="GENERATOR_TABLE",
@@ -577,16 +585,22 @@
     pkColumnValue="EMP",
     allocationSize=20
 )
+
+&lt;sequence-generator name="SEQ_GEN" 
+    sequence-name="my_sequence"
+    allocation-size="20"/&gt;
+
+//and the annotation equivalent
+
 @javax.persistence.SequenceGenerator(
     name="SEQ_GEN",
-    sequenceName="my_sequence"
+    sequenceName="my_sequence",
+    allocationSize=20
 )
-package org.hibernate.test.metadata;
          </programlisting>
 
-      <para>If <classname>package-info.java</classname> in the
-      <classname>org.hibernate.test.metadata</classname> package is used to
-      initialize the EJB configuration, <literal>EMP_GEN</literal> and
+      <para>If JPA XML (like <filename>META-INF/orm.xml</filename>) is used to
+      define thegenerators, <literal>EMP_GEN</literal> and
       <literal>SEQ_GEN</literal> are application level generators.
       <literal>EMP_GEN</literal> defines a table based id generator using the
       hilo algorithm with a <literal>max_lo</literal> of 20. The hi value is
@@ -597,11 +611,20 @@
       "<literal>hi</literal>" contains the the next high value used.</para>
 
       <para><literal>SEQ_GEN</literal> defines a sequence generator using a
-      sequence named <literal>my_sequence</literal>. Note that this version of
-      Hibernate Annotations does not handle <literal>initialValue</literal>
-      and <literal>allocationSize</literal> parameters in the sequence
-      generator.</para>
+      sequence named <literal>my_sequence</literal>. The allocation size used
+      for this sequence based hilo algorithm is 20. Note that this version of
+      Hibernate Annotations does not handle <literal>initialValue</literal> in
+      the sequence generator. The default allocation size is 50, so if you
+      want to use a sequence and pickup the value each time, you must set the
+      allocation size to 1.</para>
 
+      <note>
+        <para>Package level definition is no longer supported by the EJB 3.0
+        specification. However, you can use the
+        <literal>@GenericGenerator</literal> at the package level (see <xref
+        linkend="entity-hibspec-identifier" />).</para>
+      </note>
+
       <para>The next example shows the definition of a sequence generator in a
       class scope:</para>
 
@@ -1087,17 +1110,6 @@
         <literal>Customer</literal> table materialized by the
         <literal>joinColumns</literal> attribute.</para>
 
-        <para>The association may be bidirectional. In a bidirectional
-        relationship, one of the sides (and only one) has to be the owner: the
-        owner is responsible for the association column(s) update. To declare
-        a side as <emphasis>not</emphasis> responsible for the relationship,
-        the attribute <literal>mappedBy</literal> is used.
-        <literal>mappedBy</literal> refers to the property name of the
-        association on the owner side. In our case, this is
-        <literal>passport</literal>. As you can see, you don't have to (must
-        not) declare the join column since it has already been declared on the
-        owners side.</para>
-
         <para>You must declare the join table name and the join columns
         explicitly in such a mapping.</para>
       </sect3>
@@ -1178,7 +1190,8 @@
       <sect3 id="entity-mapping-association-collections">
         <title>Collections</title>
 
-        <sect4>
+        <sect4 id="entity-mapping-association-collections-overview"
+               revision="1">
           <title>Overview</title>
 
           <para>You can map <classname>Collection</classname>,
@@ -1245,6 +1258,16 @@
                 </row>
 
                 <row>
+                  <entry>Bag semantic with primary key (withtout the
+                  limitations of Bag semantic)</entry>
+
+                  <entry>java.util.List, java.util.Collection</entry>
+
+                  <entry>(@org.hibernate.annotations.CollectionOfElements or
+                  @OneToMany or @ManyToMany) and @CollectionId</entry>
+                </row>
+
+                <row>
                   <entry>List semantic</entry>
 
                   <entry>java.util.List</entry>
@@ -1270,8 +1293,8 @@
 
                   <entry>(@org.hibernate.annotations.CollectionOfElements or
                   @OneToMany or @ManyToMany) and (nothing or
-                  @org.hibernate.annotations.MapKey/MapKeyManyToMany for true map support, OR
-                  @javax.persistence.MapKey</entry>
+                  @org.hibernate.annotations.MapKey/MapKeyManyToMany for true
+                  map support, OR @javax.persistence.MapKey</entry>
                 </row>
               </tbody>
             </tgroup>
@@ -1465,7 +1488,8 @@
             (<literal>inversejoinColumns</literal>).</para>
           </sect5>
 
-          <sect5>
+          <sect5 id="entity-mapping-association-collection-manytomany-default"
+                 revision="1">
             <title>Defaults</title>
 
             <para>Without describing any physical mapping, a unidirectional
@@ -1504,7 +1528,8 @@
           </sect5>
         </sect4>
 
-        <sect4>
+        <sect4 id="eentity-mapping-association-collection-manytomany"
+               revision="">
           <title>Many-to-many</title>
 
           <sect5>
@@ -1596,7 +1621,7 @@
 }
                </programlisting>
 
-            <para>A <literal>Store_Table</literal> is used as the join table.
+            <para>A <literal>Store_City</literal> is used as the join table.
             The <literal>Store_id</literal> column is a foreign key to the
             <literal>Store</literal> table. The
             <literal>implantedIn_id</literal> column is a foreign key to the
@@ -1635,7 +1660,7 @@
             table. The <literal>stores_id</literal> column is a foreign key to
             the <literal>Store</literal> table. The
             <literal>customers_id</literal> column is a foreign key to the
-            <literal>City</literal> table.</para>
+            <literal>Customer</literal> table.</para>
           </sect5>
         </sect4>
       </sect3>
@@ -1701,7 +1726,7 @@
       class has to be serializable and implements
       <methodname>equals()</methodname>/<methodname>hashCode()</methodname>.
       You can also use <literal>@IdClass</literal> as described in <xref
-      linkend="mapping-identifier" />.</para>
+      linkend="entity-mapping-identifier" />.</para>
 
       <programlisting>
 @Entity
@@ -1849,22 +1874,23 @@
   <sect1 id="entity-mapping-query">
     <title>Mapping Queries</title>
 
-    <sect2>
-      <title>Mapping EJBQL/HQL queries</title>
+    <sect2 id="entity-mapping-query-hql" label="Mapping JPAQL/HQL queries"
+           revision="1">
+      <title>Mapping JPAQL/HQL queries</title>
 
       <para>You can map EJBQL/HQL queries using annotations.
       <literal>@NamedQuery</literal> and <literal>@NamedQueries</literal> can
-      be defined at the class or at the package level. However their
+      be defined at the class level or in a JPA XML file. However their
       definitions are global to the session factory/entity manager factory
       scope. A named query is defined by its name and the actual query
       string.</para>
 
-      <programlisting>
-javax.persistence.NamedQueries(
-    @javax.persistence.NamedQuery(name="plane.getAll", query="select p from Plane p")
-)
-package org.hibernate.test.annotations.query;
-
+      <programlisting>&lt;entity-mappings&gt;
+    &lt;named-query name="plane.getAll"&gt;
+        &lt;query&gt;select p from Plane p&lt;/query&gt;
+    &lt;/named-query&gt;
+    ...
+&lt;/entity-mappings&gt;
 ...
 
 @Entity
@@ -1971,18 +1997,20 @@
       <literal>@SqlResultSetMapping</literal> (or
       <literal>@SqlResultSetMappings</literal> if you plan to define several
       resulset mappings). Like <literal>@NamedQuery</literal>, a
-      <literal>@SqlResultSetMapping</literal> can be defined at both package
-      level or class level. However its scope is global to the application. As
-      we will see, a <literal>resultSetMapping</literal> parameter is defined
-      the <literal>@NamedNativeQuery</literal>, it represents the name of a
-      defined <literal>@SqlResultSetMapping</literal>. The resultset mapping
-      declares the entities retrieved by this native query. Each field of the
-      entity is bound to an SQL alias (or column name). All fields of the
-      entity including the ones of subclasses and the foreign key columns of
-      related entities have to be present in the SQL query. Field definitions
-      are optional provided that they map to the same column name as the one
-      declared on the class property.</para>
+      <literal>@SqlResultSetMapping</literal> can be defined at class level or
+      in a JPA XML file. However its scope is global to the
+      application.</para>
 
+      <para>As we will see, a <literal>resultSetMapping</literal> parameter is
+      defined in <literal>@NamedNativeQuery</literal>, it represents the name
+      of a defined <literal>@SqlResultSetMapping</literal>. The resultset
+      mapping declares the entities retrieved by this native query. Each field
+      of the entity is bound to an SQL alias (or column name). All fields of
+      the entity including the ones of subclasses and the foreign key columns
+      of related entities have to be present in the SQL query. Field
+      definitions are optional provided that they map to the same column name
+      as the one declared on the class property.</para>
+
       <para><programlisting>@NamedNativeQuery(name="night&amp;area", query="select night.id nid, night.night_duration, "
     + " night.night_date, area.id aid, night.area_id, area.name "
     + "from Night night, Area area where night.area_id = area.id", <emphasis
@@ -2302,7 +2330,7 @@
 public class Carrot extends Vegetable { ... }</programlisting></para>
     </sect2>
 
-    <sect2>
+    <sect2 id="entity-hibspec-identifier" label="Identifier" revision="1">
       <title>Identifier</title>
 
       <para><literal><literal>@org.hibernate.annotations.GenericGenerator</literal>
@@ -2326,7 +2354,20 @@
       generator strategy or the fully qualified class name of an
       <classname>IdentifierGenerator</classname> implementation. You can add
       some parameters through the <literal>parameters</literal>
-      attribute</para>
+      attribute.</para>
+
+      <para>Contrary to its standard counterpart,
+      <literal>@GenericGenerator</literal> can be used in package level
+      annotations, making it an application level generator (just like if it
+      were in a JPA XML file).</para>
+
+      <programlisting>@GenericGenerator(name="hibseq", strategy = "seqhilo",
+    parameters = {
+        @Parameter(name="max_lo", value = "5"),
+        @Parameter(name="sequence", value="heybabyhey")
+    }
+)
+package org.hibernate.test.model</programlisting>
     </sect2>
 
     <sect2 id="entity-hibspec-property" revision="2">
@@ -2575,7 +2616,7 @@
       </sect3>
     </sect2>
 
-    <sect2>
+    <sect2 id="entity-hibspec-inheritance" revision="1">
       <title>Inheritance</title>
 
       <para>SINGLE_TABLE is a very powerful strategy but sometimes, and
@@ -2590,9 +2631,17 @@
       <programlisting>@Entity
 @DiscriminatorForumla("case when forest_type is null then 0 else forest_type end")
 public class Forest { ... }</programlisting>
+
+      <para>By default, when querying the top entities, Hibernate does not put
+      a restriction clause on the discriminator column. This can be
+      inconvenient if this column contains values not mapped in your hierarchy
+      (through <literal>@DiscriminatorValue</literal>). To work around that
+      you can use <literal>@ForceDiscriminator</literal> (at the class level,
+      next to <literal>@DiscriminatorColumn</literal>). Hibernate will then
+      list the available values when loading the entities.</para>
     </sect2>
 
-    <sect2>
+    <sect2 id="entity-hibspec-singleassoc">
       <title>Single Association related annotations</title>
 
       <para>By default, when Hibernate cannot resolve the association because
@@ -2629,6 +2678,21 @@
       <para>In this case Hibernate generates a cascade delete constraint at
       the database level.</para>
 
+      <para>Foreign key constraints, while generated by Hibernate, have a
+      fairly unreadable name. You can override the constraint name by use
+      <literal>@ForeignKey</literal>.</para>
+
+      <programlisting>@Entity
+public class Child {
+    ...
+    @ManyToOne
+    <emphasis role="bold">@ForeignKey(name="FK_PARENT")</emphasis>
+    public Parent getParent() { ... }
+    ...
+}
+
+alter table Child add constraint FK_PARENT foreign key (parent_id) references Parent</programlisting>
+
       <sect3>
         <title>Lazy options and fetching modes</title>
 
@@ -2733,8 +2797,8 @@
     <sect2 id="entity-hibspec-collection" revision="2">
       <title>Collection related annotations</title>
 
-      <sect3>
-        <title>Parameter annotations</title>
+      <sect3 id="entity-hibspec-collection-enhance" revision="2">
+        <title>Enhance collection settings</title>
 
         <para>It is possible to set <itemizedlist>
             <listitem>
@@ -2742,7 +2806,7 @@
             </listitem>
 
             <listitem>
-               the where clause, using @Where 
+               the where clause, using @Where (applied on the target entity) or @WhereJoinTable (applied on the association table)
             </listitem>
 
             <listitem>
@@ -2763,7 +2827,9 @@
         you want between unsorted, natural or custom comparator. If you want
         to use your own comparator implementation, you'll also have to express
         the implementation class using the <literal>comparator</literal>
-        attribute.</para>
+        attribute. Note that you need to use either a
+        <classname>SortedSet</classname> or a <classname>SortedMap</classname>
+        interface.</para>
 
         <programlisting>    @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
     @JoinColumn(name="CUST_ID")
@@ -2776,63 +2842,187 @@
 
         <para>Please refer to the previous descriptions of these annotations
         for more informations.</para>
+
+        <para>Foreign key constraints, while generated by Hibernate, have a
+        fairly unreadable name. You can override the constraint name by use
+        <literal>@ForeignKey</literal>. Note that this annotation has to be
+        placed on the owning side of the relationship,
+        <literal>inverseName</literal> referencing to the other side
+        constraint.</para>
+
+        <programlisting>@Entity
+public class Woman {
+    ...
+    @ManyToMany(cascade = {CascadeType.ALL})
+    <emphasis role="bold">@ForeignKey(name = "TO_WOMAN_FK", inverseName = "TO_MAN_FK")</emphasis>
+    public Set&lt;Man&gt; getMens() {
+        return mens;
+    }
+}
+
+alter table Man_Woman add constraint TO_WOMAN_FK foreign key (woman_id) references Woman
+alter table Man_Woman add constraint TO_MAN_FK foreign key (man_id) references Man</programlisting>
       </sect3>
 
-      <sect3>
+      <sect3 id="entity-hibspec-collection-extratype" revision="1">
         <title>Extra collection types</title>
 
-        <para>Beyond EJB3, Hibernate Annotations supports true
-        <classname>List</classname> and <classname>Array</classname>. Map your
-        collection the same way as usual and add the
-        @<literal>IndexColumn</literal>. This annotation allows you to
-        describe the column that will hold the index. You can also declare the
-        index value in DB that represent the first element (aka as base
-        index). The usual value is <literal>0</literal> or
-        <literal>1</literal>.</para>
+        <sect4>
+          <title>List</title>
 
-        <programlisting>@OneToMany(cascade = CascadeType.ALL)
+          <para>Beyond EJB3, Hibernate Annotations supports true
+          <classname>List</classname> and <classname>Array</classname>. Map
+          your collection the same way as usual and add the
+          @<literal>IndexColumn</literal>. This annotation allows you to
+          describe the column that will hold the index. You can also declare
+          the index value in DB that represent the first element (aka as base
+          index). The usual value is <literal>0</literal> or
+          <literal>1</literal>.</para>
+
+          <programlisting>@OneToMany(cascade = CascadeType.ALL)
 @IndexColumn(name = "drawer_position", base=1)
 public List&lt;Drawer&gt; getDrawers() {
     return drawers;
 }</programlisting>
 
-        <note>
-          <para>If you forgot to set <literal>@IndexColumn</literal>, the bag
-          semantic is applied</para>
-        </note>
+          <note>
+            <para>If you forgot to set <literal>@IndexColumn</literal>, the
+            bag semantic is applied. If you want the bag semantic without the
+            limitations of it, consider using
+            <literal>@CollectionId</literal>.</para>
+          </note>
+        </sect4>
 
-        <para>Hibernate Annotations also supports true Map mappings, if
-        <literal>@javax.persistence.MapKey</literal> is not set, hibernate
-        will map the key element or embeddable object in its/their own
-        columns. To overrides the default columns, you can use
-        <literal>@org.hibernate.annotations.MapKey</literal> if your key is a basic type
-        or an embeddable object, or you canh use
-        <literal>@org.hibernate.annotations.MapKey</literal> if your key is an entity.
-        </para>
+        <sect4>
+          <title>Map</title>
 
-        <para>Hibernate Annotations also supports collections of core types
-        (Integer, String, Enums, ...), collections of embeddable objects and
-        even arrays of primitive types. This is known as collection of
-        elements.</para>
+          <para>Hibernate Annotations also supports true Map mappings, if
+          <literal>@javax.persistence.MapKey</literal> is not set, hibernate
+          will map the key element or embeddable object in its/their own
+          columns. To overrides the default columns, you can use
+          <literal>@org.hibernate.annotations.MapKey</literal> if your key is
+          a basic type (defaulted to <literal>mapkey</literal>) or an
+          embeddable object, or you can use
+          <literal>@org.hibernate.annotations.MapKeyManyToMany</literal> if
+          your key is an entity.</para>
+        </sect4>
 
-        <para>A collection of elements has to be annotated as
-        <literal>@CollectionOfElements</literal> (as a replacement of
-        <literal>@OneToMany</literal>) To define the collection table, the
-        <literal>@JoinTable</literal> annotation is used on the association
-        property, <literal>joinColumns</literal> defines the join columns
-        between the entity primary table and the collection table
-        (inverseJoincolumn is useless and should be left empty). For
-        collection of core types or array of primitive types, you can override
-        the element column definition using a <literal>@Column</literal> on
-        the association property. You can also override the columns of a
-        collection of embeddable object using
-        <literal>@AttributeOverride</literal>. To reach the collection
-        element, you need to append "element" to the attribute override name
-        (eg "element" for core types, or "element.serial" for the serial
-        property of an embeddable element). To reach the index/key of a
-        collection, append "key" instead.</para>
+        <sect4 id="entity-hibspec-collection-extratype-indexbidir">
+          <title>Bidirectional association with indexed collections</title>
 
-        <programlisting>@Entity
+          <para>A bidirectional association where one end is represented as a
+          <literal>@IndexColumn</literal> or
+          <literal>@org.hibernate.annotations.MapKey[ManyToMany]</literal>
+          requires special consideration. If there is a property of the child
+          class which maps to the index column, no problem, we can continue
+          using <literal>mappedBy</literal> on the collection mapping:</para>
+
+          <programlisting>@Entity
+public class Parent {
+    @OneToMany(mappedBy="parent")
+    @org.hibernate.annotations.MapKey(columns=@Column(name="name"))
+    private Map&lt;String, Child&gt; children;
+    ...
+}
+
+ at Entity
+public class Parent {
+    ...
+    @Basic
+    private String name;
+
+    @ManyToOne
+    @JoinColumn(name="parent_id", nullable=false)
+    private Parent parent;
+    ...
+}</programlisting>
+
+          <para>But, if there is no such property on the child class, we can't
+          think of the association as truly bidirectional (there is
+          information available at one end of the association that is not
+          available at the other end). In this case, we can't map the
+          collection <literal>mappedBy</literal>. Instead, we could use the
+          following mapping:</para>
+
+          <programlisting>@Entity
+public class Parent {
+    @OneToMany
+    @org.hibernate.annotations.MapKey(columns=@Column(name="name"))
+    @JoinColumn(name="parent_id", nullable=false)
+    private Map&lt;String, Child&gt; children;
+    ...
+}
+
+ at Entity
+public class Parent {
+    ...
+    @ManyToOne
+    @JoinColumn(name="parent_id", insertable=false, updatable=false, nullable=false)
+    private Parent parent;
+    ...
+}</programlisting>
+
+          <para>Note that in this mapping, the collection-valued end of the
+          association is responsible for updates to the foreign key.</para>
+        </sect4>
+
+        <sect4>
+          <title>Bag with primary key</title>
+
+          <para>Another interesting feature is the ability to define a
+          surrogate primary key to a bag collection. This remove pretty much
+          all of the drawbacks of bags: update and removal are efficient, more
+          than one <literal>EAGER</literal> bag per query or per entity. This
+          primary key will be contained in a additional column of your
+          collection table but will not be visible to the Java application.
+          @CollectionId is used to mark a collection as id bag, it also allow
+          to override the primary key column(s), the primary key type and the
+          generator strategy. The strategy can be <literal>identity</literal>,
+          or any defined generator name of your application.</para>
+
+          <programlisting>@Entity
+ at TableGenerator(name="ids_generator", table="IDS")
+public class Passport {
+    ...
+
+    @ManyToMany(cascade = CascadeType.ALL)
+    @JoinTable(name="PASSPORT_VISASTAMP")
+    <emphasis role="bold">@CollectionId(
+        columns = @Column(name="COLLECTION_ID"), 
+        type=@Type(type="long"), 
+        generator = "ids_generator"
+    )</emphasis>
+    private Collection&lt;Stamp&gt; visaStamp = new ArrayList();
+    ...
+}</programlisting>
+        </sect4>
+
+        <sect4>
+          <title>Collection of element or composite elements</title>
+
+          <para>Hibernate Annotations also supports collections of core types
+          (Integer, String, Enums, ...), collections of embeddable objects and
+          even arrays of primitive types. This is known as collection of
+          elements.</para>
+
+          <para>A collection of elements has to be annotated as
+          <literal>@CollectionOfElements</literal> (as a replacement of
+          <literal>@OneToMany</literal>) To define the collection table, the
+          <literal>@JoinTable</literal> annotation is used on the association
+          property, <literal>joinColumns</literal> defines the join columns
+          between the entity primary table and the collection table
+          (inverseJoincolumn is useless and should be left empty). For
+          collection of core types or array of primitive types, you can
+          override the element column definition using a
+          <literal>@Column</literal> on the association property. You can also
+          override the columns of a collection of embeddable object using
+          <literal>@AttributeOverride</literal>. To reach the collection
+          element, you need to append "element" to the attribute override name
+          (eg "element" for core types, or "element.serial" for the serial
+          property of an embeddable element). To reach the index/key of a
+          collection, append "key" instead.</para>
+
+          <programlisting>@Entity
 public class Boy {
     private Integer id;
     private Set&lt;String&gt; nickNames = new HashSet&lt;String&gt;();
@@ -2934,19 +3124,20 @@
     }
 }</programlisting>
 
-        <para>On a collection of embeddable objects, the embeddable object can
-        have a proeprty annotated with <literal>@Parent</literal>. This
-        property will then point back to the entity containing the
-        collection.</para>
+          <para>On a collection of embeddable objects, the embeddable object
+          can have a property annotated with <literal>@Parent</literal>. This
+          property will then point back to the entity containing the
+          collection.</para>
 
-        <note>
-          <para>Previous versions of Hibernate Annotations used the
-          <literal>@OneToMany</literal> to mark a collection of elements. Due
-          to semantic inconsistencies, we've introduced the annotation
-          <literal>@CollectionOfElements</literal>. Marking collections of
-          elements the old way still work but is considered deprecated and is
-          going to be unsupported in future releases</para>
-        </note>
+          <note>
+            <para>Previous versions of Hibernate Annotations used the
+            <literal>@OneToMany</literal> to mark a collection of elements.
+            Due to semantic inconsistencies, we've introduced the annotation
+            <literal>@CollectionOfElements</literal>. Marking collections of
+            elements the old way still work but is considered deprecated and
+            is going to be unsupported in future releases</para>
+          </note>
+        </sect4>
       </sect3>
     </sect2>
 
@@ -3010,20 +3201,22 @@
       </programlistingco>
     </sect2>
 
-    <sect2>
+    <sect2 id="entity-hibspec-filters">
       <title>Filters</title>
 
-      <para>Hibernate has the notion of data filter that can be applied at
-      runtime on a given session. Those filters has to be defined
-      first.</para>
+      <para>Hibernate has the ability to apply arbitrary filters on top of
+      your data. Those filters are applied at runtime on a given session.
+      First, you need to define them.</para>
 
       <para><literal>@org.hibernate.annotations.FilterDef</literal> or
       <literal>@FilterDefs</literal> define filter definition(s) used by
       filter(s) using the same name. A filter definition has a name() and an
-      array of parameters(). A <literal>@ParamDef</literal> has a name and a
-      type. You can also define a defaultCondition() parameter for a given
-      <literal>@filterDef</literal> to set the default condition to use when
-      none are defined in the <literal>@Filter</literal>. A
+      array of parameters(). A parameter will allow you to adjust the behavior
+      of the filter at runtime. Each parameter is defined by a
+      <literal>@ParamDef</literal> which has a name and a type. You can also
+      define a defaultCondition() parameter for a given
+      <literal>@FilterDef</literal> to set the default condition to use when
+      none are defined in each individual <literal>@Filter</literal>. A
       <literal>@FilterDef</literal>(s) can be defined at the class or package
       level.</para>
 
@@ -3038,9 +3231,25 @@
     @Filter(name="minLength", condition=":minLength &lt;= length")
 } )
 public class Forest { ... }</programlisting></para>
+
+      <para>When the collection use an association table as a relational
+      representation, you might want to apply the filter condition to the
+      association table itself or to the target entity table. To apply the
+      constraint on the target entity, use the regular
+      <literal>@Filter</literal> annotation. However, if you wan to target the
+      association table, use the <literal>@FilterJoinTable</literal>
+      annotation.</para>
+
+      <programlisting>    @OneToMany
+    @JoinTable
+    //filter on the target entity table
+    @Filter(name="betweenLength", condition=":minLength &lt;= length and :maxLength &gt;= length")
+    //filter on the association table
+    @FilterJoinTable(name="security", condition=":userlevel &gt;= requredLevel")
+    public Set&lt;Forest&gt; getForests() { ... }</programlisting>
     </sect2>
 
-    <sect2>
+    <sect2 id="entity-hibspec-query">
       <title>Queries</title>
 
       <para>Since Hibernate has more features on named queries than the one
@@ -3095,9 +3304,10 @@
         </listitem>
       </itemizedlist>
 
-      <para>Note, that the EJB3 public final draft has introduced the notion
-      of <literal>@QueryHint</literal>, which is probably a better way to
-      define those hints.</para>
+      <para>Those hints can be set in a standard
+      <literal>@javax.persistence.NamedQuery</literal> annotations through the
+      detyped <literal>@QueryHint</literal>. Another key advantage is the
+      ability to set those annotations at a package level.</para>
     </sect2>
   </sect1>
 </chapter>
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/lucene.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/lucene.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/lucene.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<chapter id="lucene">
-  <title id="lucene">Hibernate Lucene Integration</title>
+<chapter id="lucene" revision="1">
+  <title>Hibernate Lucene Integration</title>
 
   <para>Lucene is a high-performance Java search engine library available from
   the Apache Software Foundation. Hibernate Annotations includes a package of
@@ -8,34 +8,35 @@
   have Hibernate maintain a Lucene index of any instances persisted via
   Hibernate.</para>
 
-  <sect1 id="lucene-intro">
-    <title>Using Lucene to index your entities</title>
+  <para>Hibernate Lucene is a work in progress and new features are cooking in
+  this area. So expect some compatibility changes in subsequent
+  versions.</para>
 
-    <sect2>
-      <title>Annotating your domain model</title>
+  <section id="lucene-mapping">
+    <title>Mapping the entities to the index</title>
 
-      <para>First, we must declare a persistent class as
-      <literal>@Indexed</literal>:</para>
+    <para>First, we must declare a persistent class as indexable. This is done
+    by annotating the class with <literal>@Indexed</literal>:</para>
 
-      <programlisting>@Entity
+    <programlisting>@Entity
 @Indexed(index="indexes/essays")
 public class Essay {
     ...
 }</programlisting>
 
-      <para>The <literal>index</literal> attribute tells Hibernate where the
-      Lucene index is located (a directory on your file system). If you wish
-      to define a base directory for all lucene indexes, you can use the
-      <literal>hibernate.lucene.index_dir</literal> property in your
-      configuration file.</para>
+    <para>The <literal>index</literal> attribute tells Hibernate what the
+    lucene directory name is (usually a directory on your file system). If you
+    wish to define a base directory for all lucene indexes, you can use the
+    <literal>hibernate.lucene.default.indexDir</literal> property in your
+    configuration file.</para>
 
-      <para>Lucene indexes contain four kinds of fields:
-      <emphasis>keyword</emphasis> fields, <emphasis>text</emphasis> fields,
-      <emphasis>unstored</emphasis> fields and <emphasis>unindexed</emphasis>
-      fields. Hibernate Annotations provides annotations to mark a property of
-      an entity as one of the first three kinds of indexed fields.</para>
+    <para>Lucene indexes contain four kinds of fields:
+    <emphasis>keyword</emphasis> fields, <emphasis>text</emphasis> fields,
+    <emphasis>unstored</emphasis> fields and <emphasis>unindexed</emphasis>
+    fields. Hibernate Annotations provides annotations to mark a property of
+    an entity as one of the first three kinds of indexed fields.</para>
 
-      <programlisting>@Entity
+    <programlisting>@Entity
 @Indexed(index="indexes/essays")
 public class Essay {
     ...
@@ -53,22 +54,119 @@
     
 }</programlisting>
 
-      <para>These annotations define an index with three fields:
-      <literal>Id</literal>, <literal>Abstract</literal> and
-      <literal>Text</literal>.</para>
+    <para>These annotations define an index with three fields:
+    <literal>id</literal>, <literal>Abstract</literal> and
+    <literal>text</literal>. Note that by default the field name is
+    decapitalized, following the JavaBean specification.</para>
 
-      <para>Note: you <emphasis>must</emphasis> specify
-      <literal>@Keyword(id=true)</literal> on the identifier property of your
-      entity class.</para>
+    <para>Note: you <emphasis>must</emphasis> specify
+    <literal>@Keyword(id=true)</literal> on the identifier property of your
+    entity class.</para>
 
-      <para>The analyzer class used to index the elements is configurable
-      through the <literal>hibernate.lucene.analyzer</literal> property. If
-      none defined,
-      <classname>org.apache.lucene.analysis.standard.StandardAnalyzer</classname>
-      is used as the default.</para>
-    </sect2>
+    <para>Lucene has the notion of <emphasis>boost factor</emphasis>. It's a
+    way to give more weigth to a field or to an indexed element over an other
+    during the indexation process. You can use <literal>@Boost</literal> at
+    the field or the class level.</para>
 
-    <sect2>
+    <para>The analyzer class used to index the elements is configurable
+    through the <literal>hibernate.lucene.analyzer</literal> property. If none
+    defined,
+    <classname>org.apache.lucene.analysis.standard.StandardAnalyzer</classname>
+    is used as the default.</para>
+  </section>
+
+  <section id="lucene-configuration">
+    <title>Configuration</title>
+
+    <section id="lucene-configuration-directory">
+      <title>directory configuration</title>
+
+      <para>Lucene has a notion of Directory where the index is stored. The
+      Directory implementation can be customized but Lucene comes bundled with
+      a file system and a full memory implementation. Hibernate Lucene has the
+      notion of <literal>DirectoryProvider</literal> that handle the
+      configuration and the initialization of the Lucene Directory.</para>
+
+      <table>
+        <title>List of built-in Directory Providers</title>
+
+        <tgroup cols="3">
+          <thead>
+            <row>
+              <entry align="center">Class</entry>
+
+              <entry align="center">description</entry>
+
+              <entry align="center">Properties</entry>
+            </row>
+          </thead>
+
+          <tbody>
+            <row>
+              <entry>org.hibernate.lucene.store.FSDirectoryProvider</entry>
+
+              <entry>File system based directory. The directory used will be
+              &lt;indexBase&gt;/&lt;<literal>@Index.name</literal>&gt;</entry>
+
+              <entry><literal>indexBase</literal>: Base directory</entry>
+            </row>
+
+            <row>
+              <entry>org.hibernate.lucene.store.RAMDirectoryProvider</entry>
+
+              <entry>Memory based directory, the directory will be uniquely
+              indentified by the <literal>@Index.name</literal>
+              element</entry>
+
+              <entry>none</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+
+      <para>If the built-in directory providers does not fit your needs, you
+      can write your own directory provider by implementing the
+      <classname>org.hibernate.store.DirectoryProvider</classname>
+      interface</para>
+
+      <para>Each indexed entity is associated to a Lucene index (an index can
+      be shared by several entities but this is not usually the case). You can
+      configure the index through properties prefixed by
+      <literal><literal>hibernate.lucene.&lt;indexname&gt;</literal></literal>.
+      Default properties inherited to all indexes can be defined using the
+      prefix hibernate.lucene.default.</para>
+
+      <para>To define the directory provider of a given index, you use the
+      <literal>hibernate.lucene.&lt;indexname&gt;.directory_provider</literal></para>
+
+      <programlisting>hibernate.lucene.default.directory_provider org.hibernate.lucene.store.FSDirectoryProvider
+hibernate.lucene.default.indexDir=/usr/lucene/indexes
+
+hibernate.lucene.Rules.directory_provider org.hibernate.lucene.store.RAMDirectoryProvider
+</programlisting>
+
+      <para>applied on</para>
+
+      <programlisting>@Indexed(name="Status")
+public class Status { ... }
+
+ at Indexed(name="Rules")
+public class Rule { ... }</programlisting>
+
+      <para>will create a file system directory in
+      <filename>/usr/lucene/indexes/Status</filename> where the Status
+      entities will be indexed, and use an in memory directory named
+      <literal>Rules</literal> where Rule entities will be indexed.</para>
+
+      <para>So you can easily defined common rules like the directory provider
+      and base directory, and overide those default later on on a per index
+      basis.</para>
+
+      <para>Writing your own DirectoryProvider, you can benefit this
+      configuration mechanism too.</para>
+    </section>
+
+    <section id="lucene-configuration-event">
       <title>Enabling automatic indexing</title>
 
       <para>Finally, we enable the <literal>LuceneEventListener</literal> for
@@ -90,6 +188,6 @@
             class="org.hibernate.lucene.event.LuceneEventListener"/&gt;
     &lt;/event&gt;
 &lt;/hibernate-configuration&gt;</programlisting>
-    </sect2>
-  </sect1>
+    </section>
+  </section>
 </chapter>
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/setup.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/setup.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/setup.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -12,13 +12,15 @@
       </listitem>
 
       <listitem>
-        <para><emphasis>This preview release requires Hibernate 3.2.0.CR2 and
-        above. Do not use this release of Hibernate Annotations with an older
-        version of Hibernate 3.x!</emphasis></para>
+        <para><emphasis>This release requires Hibernate 3.2.0.CR5 and above.
+        Do not use this release of Hibernate Annotations with an older version
+        of Hibernate 3.x!</emphasis></para>
       </listitem>
 
       <listitem>
-        <para>This release is known to work on Hibernate core 3.2.0.CR2</para>
+        <para>This release is known to work on Hibernate core 3.2.0.CR5 and is
+        expected (at the time of writing) to work on Hibernate Core
+        3.2.0.GA</para>
       </listitem>
 
       <listitem>
@@ -124,7 +126,7 @@
 <emphasis role="bold">                    .addResource("test/animals/orm.xml")</emphasis>
                     .buildSessionFactory();</programlisting>
 
-    <para>You can also use the Hibernate Entity Manager which has it's own
+    <para>You can also use the Hibernate EntityManager which has its own
     configuration mechanism. Please refer to this project documentation for
     more details.</para>
 

Modified: branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/validator.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/validator.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/validator.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -219,20 +219,24 @@
     </sect2>
 
     <sect2 id="validator-constraints-error" xreflabel="Error messages">
-      <title id="validator-constraints-error">Error messages</title>
+      <title>Error messages</title>
 
       <para>Hibernate Validator comes with a default set of error messages
-      translated in a few languages (if yours is not part of it, please sent
-      us a patch). You can override those messages by creating a
+      translated in about ten languages (if yours is not part of it, please
+      sent us a patch). You can override those messages by creating a
       <filename>ValidatorMessages.properties</filename> or
-      (<filename>ValidatorMessages_loc.properties</filename>) out of
-      <filename>org.hibernate.validator.resources.DefaultValidatorMessages.properties</filename>
-      and change the appropriate keys. You can even add your own additional
-      set of messages while writing your validator annotations.</para>
+      (<filename>ValidatorMessages_loc.properties</filename>) and override the
+      needed keys. You can even add your own additional set of messages while
+      writing your validator annotations. If Hibernate Validator cannot
+      resolve a key from your resourceBundle nor from ValidatorMessage, it
+      falls back to the default built-in values.</para>
 
       <para>Alternatively you can provide a
       <classname>ResourceBundle</classname> while checking programmatically
-      the validation rules on a bean.</para>
+      the validation rules on a bean or if you want a completly different
+      interpolation mechanism, you can provide an implementation of
+      <literal>org.hibernate.validator.MessageInterpolator</literal> (check
+      the JavaDoc for more informations).</para>
     </sect2>
 
     <sect2>

Modified: branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/xml-overriding.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/xml-overriding.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/doc/reference/en/modules/xml-overriding.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<chapter id="xml-overriding">
+<chapter id="xml-overriding" label="Overriding metadata through XML">
   <title>Overriding metadata through XML</title>
 
   <para>The primary target for metadata in EJB3 is annotations, but the EJB3
@@ -12,7 +12,7 @@
 
   <para>The unit test suite shows some additional XML file samples.</para>
 
-  <section>
+  <section id="xml-overriding-principles">
     <title>Principles</title>
 
     <para>The XML deployment descriptor structure has been designed to reflect
@@ -58,7 +58,7 @@
       feature.</para>
     </section>
 
-    <section>
+    <section id="xml-overriding-principles-entity" revision="1">
       <title>Entity level metadata</title>
 
       <para>You can either define or override metadata informations on a given
@@ -138,7 +138,7 @@
           </callout>
 
           <callout arearefs="aa3">
-            <para><literal>entity</literal>: desribes an entity. </para>
+            <para><literal>entity</literal>: desribes an entity.</para>
 
             <para><literal>metadata-complete</literal> defines whether the
             metadata description for this element is complete or not (in other
@@ -146,7 +146,7 @@
             considered or not).</para>
 
             <para>An entity has to have a <literal>class</literal> attribute
-            refering the java class the metadata applies on. </para>
+            refering the java class the metadata applies on.</para>
 
             <para>You can overrides entity name through the
             <literal>name</literal> attribute, if none is defined and if an
@@ -156,7 +156,9 @@
             <para>For netadata complete (see below) element, you can define an
             <literal>access</literal> (either <literal>FIELD</literal> or
             <literal>PROPERTY</literal> (default)). For non medatada complete
-            element, the annotations driven access type is used.</para>
+            element, if <literal>access</literal> is not defined, the @Id
+            position will lead position, if <literal>access</literal> is
+            defined, the value is used.</para>
           </callout>
 
           <callout arearefs="aa4">

Modified: branches/Lucene_Integration/HibernateExt/metadata/lib/README.txt
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/lib/README.txt	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/lib/README.txt	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,5 @@
 Hibernate Metadata dependencies
 ===============================
 
-ejb3-persistence.jar (public final draft version): required
-lucene-1.4.3.jar (1.4.3): optional, useful when lucene integration is used
\ No newline at end of file
+ejb3-persistence.jar (final release version): required
+lucene-2.0.0.jar (2.0.0): optional, useful when lucene integration is used
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/metadata/lib/ejb3-persistence.jar
===================================================================
(Binary files differ)

Added: branches/Lucene_Integration/HibernateExt/metadata/lucene.txt
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/lucene.txt	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/lucene.txt	2006-10-11 04:01:11 UTC (rev 10566)
@@ -0,0 +1 @@
+break the default of @Indexed
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/metadata/readme.txt
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/readme.txt	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/readme.txt	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,9 @@
 Hibernate Annotations
 ==================================================
-Version: 3.2.0 CR1, 13.05.2006
+Version: 3.2.0 CR3, 4.10.2006
 
-THIS RELEASE OF HIBERNATE ANNOTATIONS REQUIRES HIBERNATE 3.2.0.CR2 AND DOES NOT WORK
-WITH HIBERNATE 3.1.x OR ANY OLDER VERSION OF HIBERNATE.
+THIS RELEASE OF HIBERNATE ANNOTATIONS REQUIRES HIBERNATE CORE 3.2.0.CR5 AND DOES NOT 
+WORK WITH HIBERNATE 3.1.x OR ANY OLDER VERSION OF HIBERNATE.
 
 
 Description

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotationfactory/AnnotationFactory.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotationfactory/AnnotationFactory.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotationfactory/AnnotationFactory.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -23,6 +23,9 @@
 		try {
 			return getProxyInstance( proxyClass, handler );
 		}
+		catch (RuntimeException e) {
+			throw e;
+		}
 		catch (Exception e) {
 			throw new RuntimeException( e );
 		}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/CollectionId.java (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/annotations/CollectionId.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Filter.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Filter.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Filter.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -7,7 +7,7 @@
 import java.lang.annotation.Target;
 
 /**
- * Add filters to an entity or a collection
+ * Add filters to an entity or a target entity of a collection
  *
  * @author Emmanuel Bernard
  * @author Matthew Inger

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/FilterJoinTable.java (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/annotations/FilterJoinTable.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/FilterJoinTables.java (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/annotations/FilterJoinTables.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Filters.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Filters.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Filters.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -7,7 +7,7 @@
 import java.lang.annotation.Target;
 
 /**
- * Add multiple filters to an entity or a collection
+ * Add multiple @Filters
  *
  * @author Emmanuel Bernard
  * @author Matthew Inger

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/FlushModeType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/FlushModeType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/FlushModeType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -21,6 +21,11 @@
 	COMMIT,
 	/**
 	 * see {@link org.hibernate.FlushMode.NEVER}
+	 * @deprecated use MANUAL, will be removed in a subsequent release
 	 */
-	NEVER
+	NEVER,
+	/**
+	 * see {@link org.hibernate.FlushMode.MANUAL}
+	 */
+	MANUAL
 }
\ No newline at end of file

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/ForceDiscriminator.java (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/annotations/ForceDiscriminator.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/ForeignKey.java (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/annotations/ForeignKey.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Where.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Where.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/Where.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -6,7 +6,7 @@
 import java.lang.annotation.Target;
 
 /**
- * Where clause to add to the element (Class or Collection)
+ * Where clause to add to the element Entity or target entity of a collection
  *
  * @author Emmanuel Bernard
  */

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/annotations/WhereJoinTable.java (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/annotations/WhereJoinTable.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AbstractPropertyHolder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AbstractPropertyHolder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AbstractPropertyHolder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -75,7 +75,7 @@
 	 */
 	public Column[] getOverriddenColumn(String propertyName) {
 		Column[] override = null;
-		if ( override == null && parent != null ) {
+		if ( parent != null ) {
 			override = parent.getOverriddenColumn( propertyName );
 		}
 		if ( override == null && currentPropertyColumnOverride != null ) {
@@ -92,7 +92,7 @@
 	 */
 	public JoinColumn[] getOverriddenJoinColumn(String propertyName) {
 		JoinColumn[] override = null;
-		if ( override == null && parent != null ) {
+		if ( parent != null ) {
 			override = parent.getOverriddenJoinColumn( propertyName );
 		}
 		if ( override == null && currentPropertyJoinColumnOverride != null ) {

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -42,6 +42,7 @@
 import javax.persistence.SequenceGenerator;
 import javax.persistence.SqlResultSetMapping;
 import javax.persistence.SqlResultSetMappings;
+import javax.persistence.Table;
 import javax.persistence.TableGenerator;
 import javax.persistence.Transient;
 import javax.persistence.Version;
@@ -58,6 +59,7 @@
 import org.hibernate.annotations.Cascade;
 import org.hibernate.annotations.CascadeType;
 import org.hibernate.annotations.Check;
+import org.hibernate.annotations.CollectionId;
 import org.hibernate.annotations.CollectionOfElements;
 import org.hibernate.annotations.Columns;
 import org.hibernate.annotations.Fetch;
@@ -65,9 +67,9 @@
 import org.hibernate.annotations.FilterDef;
 import org.hibernate.annotations.FilterDefs;
 import org.hibernate.annotations.Filters;
+import org.hibernate.annotations.ForeignKey;
 import org.hibernate.annotations.Formula;
 import org.hibernate.annotations.GenericGenerator;
-import org.hibernate.annotations.Index;
 import org.hibernate.annotations.LazyToOne;
 import org.hibernate.annotations.LazyToOneOption;
 import org.hibernate.annotations.MapKeyManyToMany;
@@ -85,6 +87,7 @@
 import org.hibernate.annotations.TypeDef;
 import org.hibernate.annotations.TypeDefs;
 import org.hibernate.annotations.Where;
+import org.hibernate.annotations.Index;
 import org.hibernate.cfg.annotations.CollectionBinder;
 import org.hibernate.cfg.annotations.EntityBinder;
 import org.hibernate.cfg.annotations.Nullability;
@@ -109,7 +112,6 @@
 import org.hibernate.mapping.SimpleValue;
 import org.hibernate.mapping.SingleTableSubclass;
 import org.hibernate.mapping.Subclass;
-import org.hibernate.mapping.Table;
 import org.hibernate.mapping.ToOne;
 import org.hibernate.mapping.UnionSubclass;
 import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
@@ -133,7 +135,6 @@
  * @author Emmanuel Bernard
  */
 public final class AnnotationBinder {
-	public static final String ANNOTATION_STRING_DEFAULT = "";
 
 	/*
 	 * Some design description
@@ -303,24 +304,24 @@
 			idGen.setName( tabGen.name() );
 			idGen.setIdentifierGeneratorStrategy( MultipleHiLoPerTableGenerator.class.getName() );
 
-			if ( !isDefault( tabGen.table() ) ) {
+			if ( ! BinderHelper.isDefault( tabGen.table() ) ) {
 				idGen.addParam( MultipleHiLoPerTableGenerator.ID_TABLE, tabGen.table() );
 			}
-			if ( ! isDefault( tabGen.catalog() ) ) {
+			if ( ! BinderHelper.isDefault( tabGen.catalog() ) ) {
 				idGen.addParam( MultipleHiLoPerTableGenerator.CATALOG, tabGen.catalog() );
 			}
-			if ( ! isDefault( tabGen.schema() ) ) {
+			if ( ! BinderHelper.isDefault( tabGen.schema() ) ) {
 				idGen.addParam( MultipleHiLoPerTableGenerator.SCHEMA, tabGen.schema() );
 			}
 			//FIXME implements uniqueconstrains
 
-			if ( ! isDefault( tabGen.pkColumnName() ) ) {
+			if ( ! BinderHelper.isDefault( tabGen.pkColumnName() ) ) {
 				idGen.addParam( MultipleHiLoPerTableGenerator.PK_COLUMN_NAME, tabGen.pkColumnName() );
 			}
-			if ( ! isDefault( tabGen.valueColumnName() ) ) {
+			if ( ! BinderHelper.isDefault( tabGen.valueColumnName() ) ) {
 				idGen.addParam( MultipleHiLoPerTableGenerator.VALUE_COLUMN_NAME, tabGen.valueColumnName() );
 			}
-			if ( !isDefault( tabGen.pkColumnValue() ) ) {
+			if ( ! BinderHelper.isDefault( tabGen.pkColumnValue() ) ) {
 				idGen.addParam( MultipleHiLoPerTableGenerator.PK_VALUE_NAME, tabGen.pkColumnValue() );
 			}
 			idGen.addParam( TableHiLoGenerator.MAX_LO, String.valueOf( tabGen.allocationSize() - 1 ) );
@@ -331,7 +332,7 @@
 			idGen.setName( seqGen.name() );
 			idGen.setIdentifierGeneratorStrategy( "seqhilo" );
 
-			if ( ! isDefault( seqGen.sequenceName() ) ) {
+			if ( ! BinderHelper.isDefault( seqGen.sequenceName() ) ) {
 				idGen.addParam( org.hibernate.id.SequenceGenerator.SEQUENCE, seqGen.sequenceName() );
 			}
 			//FIXME: work on initialValue() through SequenceGenerator.PARAMETERS
@@ -537,6 +538,11 @@
 					constraints, inheritanceState.hasDenormalizedTable() ? superEntity.getTable() : null
 			);
 		}
+		else {
+			if ( annotatedClass.isAnnotationPresent( Table.class ) ) {
+				log.warn( "Illegal use of @Table in a subclass of a SINGLE_TABLE hierarchy: " + clazzToProcess.getName() );
+			}
+		}
 //		Map<String, Column[]> columnOverride = PropertyHolderBuilder.buildHierarchyColumnOverride(
 //				clazzToProcess,
 //				persistentClass.getClassName()
@@ -572,6 +578,7 @@
 				key.setCascadeDeleteEnabled( false );
 			}
 			TableBinder.bindFk( jsc.getSuperclass(), jsc, inheritanceJoinedColumns, key, false, mappings );
+			//no need to handle inSecondPass this is an Etntiy related work
 			mappings.addSecondPass( new CreateKeySecondPass( jsc ) );
 
 		}
@@ -645,7 +652,7 @@
 			boolean propertyAnnotated = entityBinder.isPropertyAnnotated( compositeClass );
 			String propertyAccessor = entityBinder.getPropertyAccessor( compositeClass );
 			String generatorType = "assigned";
-			String generator = ANNOTATION_STRING_DEFAULT;
+			String generator = BinderHelper.ANNOTATION_STRING_DEFAULT;
 			PropertyData inferredData = new PropertyPreloadedData(
 					entityBinder.getPropertyAccessor(), "id", compositeClass
 			);
@@ -674,7 +681,7 @@
 					propertyAccessor, false,
 					entityBinder,
 					true, true,
-					mappings
+					false, mappings
 			);
 			persistentClass.setIdentifierMapper( mapper );
 			Property property = new Property();
@@ -701,7 +708,7 @@
 						subclassAndSingleTableStrategy ? Nullability.FORCED_NULL : Nullability.NO_CONSTRAINT,
 						propertyAnnotatedElement.getProperty(),
 						propertyAnnotatedElement, classGenerators, entityBinder,
-						false, false, mappings
+						false, false, false, mappings
 				);
 			}
 			else {
@@ -723,6 +730,7 @@
 
 		if ( ! inheritanceState.hasParents ) {
 			final RootClass rootClass = (RootClass) persistentClass;
+			//no need to handle inSecondPass this is an Etntiy related work
 			mappings.addSecondPass( new CreateKeySecondPass( rootClass ) );
 		}
 		else {
@@ -783,8 +791,7 @@
 
 		for ( int index = 0; index < deep ; index++ ) {
 			XClass clazz = classesToProcess.get( index );
-			InheritanceState state = inheritanceStatePerClass.get( clazz );
-
+			
 			boolean currentHasIdentifier = addElementsOfAClass(
 					elements, propertyHolder, isPropertyAnnotated,
 					accessType, clazz, mappings
@@ -799,7 +806,6 @@
 			elements.clear();
 			for ( int index = 0; index < deep ; index++ ) {
 				XClass clazz = classesToProcess.get( index );
-				InheritanceState state = inheritanceStatePerClass.get( clazz );
 				boolean currentHasIdentifier = addElementsOfAClass(
 						elements, propertyHolder, isPropertyAnnotated,
 						accessType, clazz, mappings
@@ -934,9 +940,11 @@
 		log.debug( "Processing " + propertyHolder.getEntityName() + " " + accessType + " annotation" );
 		List<XProperty> properties = annotatedClass.getDeclaredProperties( accessType );
 		for ( XProperty p : properties ) {
-			if ( !p.isTypeResolved() && !hasExplicitTargetEntity( p ) && !mustBeSkipped( p, mappings ) ) {
-				throw new IllegalStateException(
-						"Property " + p + " has an unbound type and no explicit target entity."
+			if ( !p.isTypeResolved() && !discoverTypeWithoutReflection( p ) && !mustBeSkipped( p, mappings ) ) {
+				throw new AnnotationException(
+						"Property " + StringHelper.qualify( propertyHolder.getEntityName(), p.getName() ) +
+								" has an unbound type and no explicit target entity. Resolve this Generic usage issue" +
+								" or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type"
 				);
 			}
 			final boolean currentHasIdentifier = addProperty( p, elements, localPropertyAccessor, mappings );
@@ -945,7 +953,7 @@
 		return hasIdentifier;
 	}
 
-	private static boolean hasExplicitTargetEntity(XProperty p) {
+	private static boolean discoverTypeWithoutReflection(XProperty p) {
 		if ( p.isAnnotationPresent( OneToOne.class ) && !p.getAnnotation( OneToOne.class )
 				.targetEntity()
 				.equals( void.class ) ) {
@@ -966,6 +974,9 @@
 				.equals( void.class ) ) {
 			return true;
 		}
+		if (p.isAnnotationPresent( Type.class ) ) {
+			return true;
+		}
 		return false;
 	}
 
@@ -1007,9 +1018,14 @@
 			PropertyHolder propertyHolder, Nullability nullability, XProperty property,
 			PropertyData inferredData, HashMap<String, IdGenerator> classGenerators,
 			EntityBinder entityBinder, boolean isIdentifierMapper,
-			boolean isComponentEmbedded, ExtendedMappings mappings
+			boolean isComponentEmbedded, boolean inSecondPass, ExtendedMappings mappings
 	)
 			throws MappingException {
+		/**
+		 * inSecondPass can only be used to apply right away the second pass of a composite-element
+		 * Because it's a value type, there is no bidirectional association, hence second pass
+		 * ordering does not matter
+		 */
 		Ejb3Column[] columns = null;
 		Ejb3JoinColumn[] joinColumns = null;
 		if ( log.isDebugEnabled() ) {
@@ -1118,21 +1134,6 @@
 			);
 		}
 
-		//init index
-		Index index = property.getAnnotation( Index.class );
-		if ( index != null ) {
-			if ( joinColumns != null ) {
-				for ( Ejb3Column column : joinColumns ) {
-					column.addIndex( index );
-				}
-			}
-			else {
-				for ( Ejb3Column column : columns ) {
-					column.addIndex( index );
-				}
-			}
-		}
-
 		if ( nullability == Nullability.FORCED_NOT_NULL ) {
 			//force columns to not null
 			for ( Ejb3Column col : columns ) {
@@ -1164,7 +1165,7 @@
 
 			GeneratedValue generatedValue = property.getAnnotation( GeneratedValue.class );
 			String generatorType = generatedValue != null ? generatorType( generatedValue.strategy() ) : "assigned";
-			String generator = generatedValue != null ? generatedValue.generator() : ANNOTATION_STRING_DEFAULT;
+			String generator = generatedValue != null ? generatedValue.generator() : BinderHelper.ANNOTATION_STRING_DEFAULT;
 			if ( isComponent ) generatorType = "assigned"; //a component must not have any generator
 			Type typeAnn = property.getAnnotation( Type.class );
 			bindId(
@@ -1254,7 +1255,7 @@
 					ignoreNotFound, onDeleteCascade,
 					mappings.getReflectionManager().toXClass( ann.targetEntity() ),
 					propertyHolder,
-					inferredData, false, isIdentifierMapper, mappings
+					inferredData, false, isIdentifierMapper, inSecondPass, mappings
 			);
 		}
 		else if ( property.isAnnotationPresent( OneToOne.class ) ) {
@@ -1290,7 +1291,7 @@
 					ignoreNotFound, onDeleteCascade,
 					mappings.getReflectionManager().toXClass( ann.targetEntity() ),
 					propertyHolder,
-					inferredData, ann.mappedBy(), trueOneToOne, isIdentifierMapper, mappings
+					inferredData, ann.mappedBy(), trueOneToOne, isIdentifierMapper, inSecondPass, mappings
 			);
 		}
 		else if ( property.isAnnotationPresent( OneToMany.class )
@@ -1309,7 +1310,7 @@
 			);
 			CollectionBinder collectionBinder = CollectionBinder.getCollectionBinder(
 					propertyHolder.getEntityName(),
-					inferredData,
+					property,
 					! indexColumn.isImplicit()
 			);
 			collectionBinder.setIndexColumn( indexColumn );
@@ -1326,19 +1327,7 @@
 			collectionBinder.setSort( sortAnn );
 			Cache cachAnn = property.getAnnotation( Cache.class );
 			collectionBinder.setCache( cachAnn );
-			Filter filterAnn = property.getAnnotation( Filter.class );
-			if ( filterAnn != null ) {
-				collectionBinder.addFilter( filterAnn.name(), filterAnn.condition() );
-			}
-			Filters filtersAnn = property.getAnnotation( Filters.class );
-			if ( filtersAnn != null ) {
-				for ( Filter filter : filtersAnn.value() ) {
-					collectionBinder.addFilter( filter.name(), filter.condition() );
-				}
-			}
 			collectionBinder.setPropertyHolder( propertyHolder );
-			Where whereAnn = property.getAnnotation( Where.class );
-			collectionBinder.setWhere( whereAnn );
 			Cascade hibernateCascade = property.getAnnotation( Cascade.class );
 			NotFound notFound = property.getAnnotation( NotFound.class );
 			boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE );
@@ -1348,7 +1337,7 @@
 			collectionBinder.setPropertyAccessorName( inferredData.getDefaultAccess() );
 
 			Ejb3Column[] elementColumns = null;
-			PropertyData wrappedInferredData = new WrappedInferredData( inferredData, "element" );
+			PropertyData virtualProperty = new WrappedInferredData( inferredData, "element" );
 			if ( property.isAnnotationPresent( Column.class ) || property.isAnnotationPresent(
 					Formula.class
 			) ) {
@@ -1359,7 +1348,7 @@
 						formulaAnn,
 						nullability,
 						propertyHolder,
-						wrappedInferredData,
+						virtualProperty,
 						entityBinder.getSecondaryTables(),
 						mappings
 				);
@@ -1367,7 +1356,7 @@
 			else if ( property.isAnnotationPresent( Columns.class ) ) {
 				Columns anns = property.getAnnotation( Columns.class );
 				elementColumns = Ejb3Column.buildColumnFromAnnotation(
-						anns.columns(), null, nullability, propertyHolder, wrappedInferredData,
+						anns.columns(), null, nullability, propertyHolder, virtualProperty,
 						entityBinder.getSecondaryTables(), mappings
 				);
 			}
@@ -1377,7 +1366,7 @@
 						null,
 						nullability,
 						propertyHolder,
-						wrappedInferredData,
+						virtualProperty,
 						entityBinder.getSecondaryTables(),
 						mappings
 				);
@@ -1386,13 +1375,13 @@
 			org.hibernate.annotations.MapKey hibMapKeyAnn = property.getAnnotation(
 					org.hibernate.annotations.MapKey.class
 			);
-			wrappedInferredData = new WrappedInferredData( inferredData, "key" );
+			PropertyData mapKeyVirtualProperty = new WrappedInferredData( inferredData, "mapkey" );
 			Ejb3Column[] mapColumns = Ejb3Column.buildColumnFromAnnotation(
 					hibMapKeyAnn != null && hibMapKeyAnn.columns().length > 0 ? hibMapKeyAnn.columns() : null,
 					null,
 					Nullability.FORCED_NOT_NULL,
 					propertyHolder,
-					wrappedInferredData,
+					mapKeyVirtualProperty,
 					entityBinder.getSecondaryTables(),
 					mappings
 			);
@@ -1402,7 +1391,7 @@
 			Ejb3JoinColumn[] mapJoinColumns = Ejb3JoinColumn.buildJoinColumns(
 					mapKeyManyToMany != null ? mapKeyManyToMany.joinColumns() : null,
 					null, entityBinder.getSecondaryTables(),
-					propertyHolder, wrappedInferredData.getPropertyName(), mappings
+					propertyHolder, mapKeyVirtualProperty.getPropertyName(), mappings
 			);
 			collectionBinder.setMapKeyManyToManyColumns( mapJoinColumns );
 
@@ -1466,7 +1455,14 @@
 				collectionBinder.setInsertable( false );
 				collectionBinder.setUpdatable( false );
 			}
+			if ( property.isAnnotationPresent( CollectionId.class ) ) { //do not compute the generators unless necessary
+				HashMap<String, IdGenerator> localGenerators = (HashMap<String, IdGenerator>) classGenerators.clone();
+				localGenerators.putAll( buildLocalGenerators( property, mappings ) );
+				collectionBinder.setLocalGenerators(localGenerators);
+
+			}
 			collectionBinder.bind();
+
 		}
 		else {
 			//define whether the type is a component or not
@@ -1521,6 +1517,21 @@
 				propBinder.bind();
 			}
 		}
+		//init index
+		//process indexes after everything: in second pass, many to one has to be done before indexes
+		Index index = property.getAnnotation( Index.class );
+		if ( index != null ) {
+			if ( joinColumns != null ) {
+				for ( Ejb3Column column : joinColumns ) {
+					column.addIndex( index, inSecondPass );
+				}
+			}
+			else {
+				for ( Ejb3Column column : columns ) {
+					column.addIndex( index, inSecondPass );
+				}
+			}
+		}
 	}
 
 	//TODO move that to collection binder?
@@ -1534,9 +1545,9 @@
 		JoinColumn[] annInverseJoins;
 		if ( joinTableAnn != null ) {
 			collectionBinder.setExplicitAssociationTable( true );
-			if ( ! isDefault( joinTableAnn.schema() ) ) associationTableBinder.setSchema( joinTableAnn.schema() );
-			if ( ! isDefault( joinTableAnn.catalog() ) ) associationTableBinder.setCatalog( joinTableAnn.catalog() );
-			if ( ! isDefault( joinTableAnn.name() ) ) associationTableBinder.setName( joinTableAnn.name() );
+			if ( ! BinderHelper.isDefault( joinTableAnn.schema() ) ) associationTableBinder.setSchema( joinTableAnn.schema() );
+			if ( ! BinderHelper.isDefault( joinTableAnn.catalog() ) ) associationTableBinder.setCatalog( joinTableAnn.catalog() );
+			if ( ! BinderHelper.isDefault( joinTableAnn.name() ) ) associationTableBinder.setName( joinTableAnn.name() );
 			associationTableBinder.setUniqueConstraints( joinTableAnn.uniqueConstraints() );
 
 			//set check constaint in the second pass
@@ -1588,7 +1599,7 @@
 		Component comp = fillComponent(
 				propertyHolder, inferredData, propertyAnnotated, propertyAccessor, true, entityBinder,
 				isComponentEmbedded, isIdentifierMapper,
-				mappings
+				false, mappings
 		);
 
 		PropertyBinder binder = new PropertyBinder();
@@ -1604,8 +1615,13 @@
 			PropertyHolder propertyHolder, PropertyData inferredData,
 			boolean propertyAnnotated, String propertyAccessor, boolean isNullable,
 			EntityBinder entityBinder,
-			boolean isComponentEmbedded, boolean isIdentifierMapper, ExtendedMappings mappings
+			boolean isComponentEmbedded, boolean isIdentifierMapper, boolean inSecondPass, ExtendedMappings mappings
 	) {
+		/**
+		 * inSecondPass can only be used to apply right away the second pass of a composite-element
+		 * Because it's a value type, there is no bidirectional association, hence second pass
+		 * ordering does not matter
+		 */
 		Component comp = new Component( propertyHolder.getPersistentClass() );
 		comp.setEmbedded( isComponentEmbedded );
 		//yuk
@@ -1647,7 +1663,7 @@
 					subHolder, isNullable ? Nullability.NO_CONSTRAINT : Nullability.FORCED_NOT_NULL,
 					propertyAnnotatedElement.getProperty(), propertyAnnotatedElement,
 					new HashMap<String, IdGenerator>(), entityBinder, isIdentifierMapper, isComponentEmbedded,
-					mappings
+					inSecondPass, mappings
 			);
 		}
 		return comp;
@@ -1678,7 +1694,7 @@
 		if ( isComposite ) {
 			id = fillComponent(
 					propertyHolder, inferredData, isPropertyAnnotated, propertyAccessor,
-					false, entityBinder, isEmbedded, isIdentifierMapper, mappings
+					false, entityBinder, isEmbedded, isIdentifierMapper, false, mappings
 			);
 			Component componentId = (Component) id;
 			componentId.setKey( true );
@@ -1700,47 +1716,7 @@
 			id = value.make();
 		}
 		rootClass.setIdentifier( id );
-		Table table = id.getTable();
-		table.setIdentifierValue( id );
-		//generator settings
-		id.setIdentifierGeneratorStrategy( generatorType );
-		Properties params = new Properties();
-		//always settable
-		params.setProperty(
-				PersistentIdentifierGenerator.TABLE, table.getName()
-		);
-
-		if ( id.getColumnSpan() == 1 ) {
-			params.setProperty(
-					PersistentIdentifierGenerator.PK,
-					( (org.hibernate.mapping.Column) id.getColumnIterator().next() ).getName()
-			);
-		}
-		if ( ! isDefault( generatorName ) ) {
-			//we have a named generator
-			IdGenerator gen = mappings.getGenerator( generatorName, localGenerators );
-			if ( gen == null ) {
-				throw new AnnotationException( "Unknown Id.generator: " + generatorName );
-			}
-			//This is quite vague in the spec but a generator could override the generate choice
-			String identifierGeneratorStrategy = gen.getIdentifierGeneratorStrategy();
-			//yuk! this is a hack not to override 'AUTO' even if generator is set
-			final boolean avoidOverriding =
-					identifierGeneratorStrategy.equals( "identity" )
-							|| identifierGeneratorStrategy.equals( "seqhilo" )
-							|| identifierGeneratorStrategy.equals( MultipleHiLoPerTableGenerator.class.getName() );
-			if ( ! avoidOverriding ) {
-				id.setIdentifierGeneratorStrategy( identifierGeneratorStrategy );
-			}
-			//checkIfMatchingGenerator(gen, generatorType, generatorName);
-			Iterator genParams = gen.getParams().entrySet().iterator();
-			while ( genParams.hasNext() ) {
-				Map.Entry elt = (Map.Entry) genParams.next();
-				params.setProperty( (String) elt.getKey(), (String) elt.getValue() );
-			}
-		}
-		if ( generatorType == "assigned" ) id.setNullValue( "undefined" );
-		id.setIdentifierGeneratorProperties( params );
+		BinderHelper.makeIdGenerator( id, generatorType, generatorName, mappings, localGenerators );
 		if ( isEmbedded ) {
 			rootClass.setEmbeddedIdentifier( inferredData.getPropertyClass() == null );
 		}
@@ -1759,7 +1735,8 @@
 			String cascadeStrategy, Ejb3JoinColumn[] columns, boolean optional,
 			boolean ignoreNotFound, boolean cascadeOnDelete,
 			XClass targetEntity, PropertyHolder propertyHolder,
-			PropertyData inferredData, boolean unique, boolean isIdentifierMapper, ExtendedMappings mappings
+			PropertyData inferredData, boolean unique, boolean isIdentifierMapper, boolean inSecondPass,
+			ExtendedMappings mappings
 	) {
 		//All FK columns should be in the same table
 		org.hibernate.mapping.ManyToOne value = new org.hibernate.mapping.ManyToOne( columns[0].getTable() );
@@ -1783,15 +1760,25 @@
 		final String propertyName = inferredData.getPropertyName();
 		value.setTypeUsingReflection( propertyHolder.getClassName(), propertyName );
 
-		//value.createForeignKey();
+		ForeignKey fk = inferredData.getProperty().getAnnotation( ForeignKey.class );
+		String fkName = fk != null ? fk.name() : "";
+		if ( ! BinderHelper.isDefault( fkName ) ) value.setForeignKeyName( fkName );
+
 		String path = propertyHolder.getPath() + "." + propertyName;
-		mappings.addSecondPass(
-				new FkSecondPass(
-						value, columns,
-						!optional && unique, //cannot have nullabe and unique on certain DBs
-						path, mappings
-				)
+		FkSecondPass secondPass = new FkSecondPass(
+				value, columns,
+				!optional && unique, //cannot have nullabe and unique on certain DBs like Derby
+				propertyHolder.getEntityOwnerClassName(),
+				path, mappings
 		);
+		if (inSecondPass) {
+			secondPass.doSecondPass( mappings.getClasses() );
+		}
+		else {
+			mappings.addSecondPass(
+					secondPass
+			);
+		}
 		Ejb3Column.checkPropertyConsistency( columns, propertyHolder.getEntityName() + propertyName );
 		PropertyBinder binder = new PropertyBinder();
 		binder.setName( propertyName );
@@ -1869,7 +1856,7 @@
 			PropertyHolder propertyHolder,
 			PropertyData inferredData, String mappedBy,
 			boolean trueOneToOne,
-			boolean isIdentifierMapper, ExtendedMappings mappings
+			boolean isIdentifierMapper, boolean inSecondPass, ExtendedMappings mappings
 	) {
 		//column.getTable() => persistentClass.getTable()
 		final String propertyName = inferredData.getPropertyName();
@@ -1891,25 +1878,31 @@
 				}
 			}
 		}
-		if ( trueOneToOne || mapToPK || ! isDefault( mappedBy ) ) {
+		if ( trueOneToOne || mapToPK || ! BinderHelper.isDefault( mappedBy ) ) {
 			//is a true one-to-one
 			//FIXME referencedColumnName ignored => ordering may fail.
-			mappings.addSecondPass(
-					new OneToOneSecondPass(
-							mappedBy,
-							propertyHolder.getEntityName(),
-							propertyName,
-							propertyHolder, inferredData, targetEntity, ignoreNotFound, cascadeOnDelete,
-							optional, cascadeStrategy, joinColumns, mappings
-					)
+			OneToOneSecondPass secondPass = new OneToOneSecondPass(
+					mappedBy,
+					propertyHolder.getEntityName(),
+					propertyName,
+					propertyHolder, inferredData, targetEntity, ignoreNotFound, cascadeOnDelete,
+					optional, cascadeStrategy, joinColumns, mappings
 			);
+			if (inSecondPass) {
+				secondPass.doSecondPass( mappings.getClasses() );
+			}
+			else {
+				mappings.addSecondPass(
+						secondPass
+				);
+			}
 		}
 		else {
 			//has a FK on the table
 			bindManyToOne(
 					cascadeStrategy, joinColumns, optional, ignoreNotFound, cascadeOnDelete,
 					targetEntity,
-					propertyHolder, inferredData, true, isIdentifierMapper, mappings
+					propertyHolder, inferredData, true, isIdentifierMapper, inSecondPass, mappings
 			);
 		}
 	}
@@ -2038,10 +2031,6 @@
 		return generators;
 	}
 
-	public static boolean isDefault(String annotationString) {
-		return ANNOTATION_STRING_DEFAULT.equals( annotationString );
-	}
-
 	public static boolean isDefault(XClass clazz, ExtendedMappings mappings) {
 		return mappings.getReflectionManager().equals( clazz, void.class );
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -6,7 +6,6 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -15,6 +14,9 @@
 import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
+import java.util.TreeSet;
+import java.util.SortedSet;
+import java.util.Comparator;
 import javax.persistence.Entity;
 import javax.persistence.MappedSuperclass;
 
@@ -27,6 +29,7 @@
 import org.dom4j.io.SAXReader;
 import org.hibernate.AnnotationException;
 import org.hibernate.MappingException;
+import org.hibernate.AssertionFailure;
 import org.hibernate.cfg.annotations.Version;
 import org.hibernate.mapping.Column;
 import org.hibernate.mapping.Join;
@@ -77,7 +80,7 @@
 	private List<Document> hbmDocuments; //user ordering matters, hence the list
 	private String precedence = null;
 	private boolean inSecondPass = false;
-	private ReflectionManager reflectionManager;
+	private transient ReflectionManager reflectionManager;
 	private boolean isDefaultProcessed = false;
 
 	public AnnotationConfiguration() {
@@ -236,10 +239,10 @@
 			for ( XClass clazz : annotatedClasses ) {
 				if ( clazz.isAnnotationPresent( Entity.class ) ) {
 					annotatedClassEntities.put( clazz.getName(), clazz );
-					tempAnnotatedClasses.add(clazz);
+					tempAnnotatedClasses.add( clazz );
 				}
-				else if (clazz.isAnnotationPresent( MappedSuperclass.class ) ) {
-					tempAnnotatedClasses.add(clazz);
+				else if ( clazz.isAnnotationPresent( MappedSuperclass.class ) ) {
+					tempAnnotatedClasses.add( clazz );
 				}
 				//only keep MappedSuperclasses and Entity in this list
 			}
@@ -279,26 +282,17 @@
 		}
 		caches.clear();
 
-		log.debug( "processing manytoone fk mappings" );
+		inSecondPass = true;
+		processFkSecondPassInOrder();
 		Iterator iter = secondPasses.iterator();
 		while ( iter.hasNext() ) {
 			SecondPass sp = (SecondPass) iter.next();
 			//do the second pass of fk before the others and remove them
-			if ( sp instanceof FkSecondPass ) {
-				sp.doSecondPass( classes, Collections.EMPTY_MAP ); // TODO: align meta-attributes with normal bind...
-				iter.remove();
-			}
-		}
-		iter = secondPasses.iterator();
-		while ( iter.hasNext() ) {
-			SecondPass sp = (SecondPass) iter.next();
-			//do the second pass of fk before the others and remove them
 			if ( sp instanceof CreateKeySecondPass ) {
-				sp.doSecondPass( classes, Collections.EMPTY_MAP ); // TODO: align meta-attributes with normal bind...
+				sp.doSecondPass( classes );
 				iter.remove();
 			}
 		}
-		inSecondPass = true;
 		super.secondPassCompile();
 		inSecondPass = false;
 		Iterator tables = (Iterator<Map.Entry<Table, List<String[]>>>) tableUniqueConstraints.entrySet().iterator();
@@ -331,6 +325,111 @@
 		}
 	}
 
+	private void processFkSecondPassInOrder() {
+		log.debug( "processing manytoone fk mappings" );
+		Iterator iter = secondPasses.iterator();
+		/* We need to process FKSecond pass trying to resolve any
+		 * graph circularity (ie PK made of a many to one linking to
+		 * an entity having a PK made of a ManyToOne ...
+		 */
+		SortedSet<FkSecondPass> fkSecondPasses = new TreeSet<FkSecondPass>(
+				new Comparator() {
+					//The comparator implementation has to respect the compare=0 => equals() = true for sets
+					public int compare(Object o1, Object o2) {
+						if (! (o1 instanceof FkSecondPass &&  o2 instanceof FkSecondPass) ) {
+							throw new AssertionFailure("comparint FkSecondPass with non FkSecondPass");
+						}
+						FkSecondPass f1 = (FkSecondPass) o1;
+						FkSecondPass f2 = (FkSecondPass) o2;
+						int compare = f1.getValue().getTable().getQuotedName().compareTo(
+								f2.getValue().getTable().getQuotedName()
+						);
+						if (compare == 0) {
+							//same table, we still need to differenciate true equality
+							if ( f1.hashCode() < f2.hashCode() ) {
+								compare = -1;
+							}
+							else if ( f1.hashCode() == f2.hashCode() ) {
+								compare = 0;
+							}
+							else {
+								compare = 1;
+							}
+						}
+						return compare;
+					}
+				}
+		);
+		while ( iter.hasNext() ) {
+			SecondPass sp = (SecondPass) iter.next();
+			//do the second pass of fk before the others and remove them
+			if ( sp instanceof FkSecondPass ) {
+				fkSecondPasses.add( (FkSecondPass) sp );
+				iter.remove();
+			}
+		}
+		if ( fkSecondPasses.size() > 0 ) {
+			Map<String, Set<String>> isADependencyOf = new HashMap<String, Set<String>>();
+			List orderedFkSecondPasses = new ArrayList( fkSecondPasses.size() );
+			List endOfQueueFkSecondPasses = new ArrayList( fkSecondPasses.size() );
+			List orderedTable = new ArrayList( fkSecondPasses.size() );
+			Iterator it = fkSecondPasses.iterator();
+			while ( it.hasNext() ) {
+				FkSecondPass sp = (FkSecondPass) it.next();
+				String referenceEntityName = sp.getValue().getReferencedEntityName();
+				PersistentClass classMapping = getClassMapping( referenceEntityName );
+				if ( sp.isInPrimaryKey() ) {
+					String dependentTable = classMapping.getTable().getQuotedName();
+					if ( ! isADependencyOf.containsKey( dependentTable ) ) {
+						isADependencyOf.put( dependentTable, new HashSet<String>() );
+					}
+					String table = sp.getValue().getTable().getQuotedName();
+					isADependencyOf.get( dependentTable ).add( table );
+					int beAfter = orderedTable.indexOf( dependentTable );
+					int beBefore = orderedFkSecondPasses.size();
+					Set<String> dependencies = isADependencyOf.get( table );
+					if ( dependencies != null ) {
+						for ( String tableDep : dependencies ) {
+							//for each declared dependency take the lowest index
+							int index = orderedTable.indexOf( tableDep );
+							//index = -1 when we have a self dependency
+							beBefore = index != -1 && index < beBefore ? index : beBefore;
+						}
+					}
+					int currentIndex = orderedTable.indexOf( table );
+					if ( beBefore < beAfter ||
+							( currentIndex != -1 && ( currentIndex < beAfter || currentIndex > beBefore ) )
+							) {
+						StringBuilder sb = new StringBuilder(
+								"Foreign key circularity dependency involving the following tables: "
+						);
+						//TODO deduplicate tables
+						sb.append( table );
+						if ( beAfter > -1 ) sb.append( ", " ).append( dependentTable );
+						if ( beBefore < orderedFkSecondPasses.size() ) {
+							sb.append( ", " ).append( orderedTable.get( beBefore ) );
+						}
+						throw new AnnotationException( sb.toString() );
+					}
+					currentIndex = currentIndex == -1 ? beBefore : currentIndex;
+					orderedTable.add( currentIndex, table );
+					orderedFkSecondPasses.add( currentIndex, sp );
+				}
+				else {
+					endOfQueueFkSecondPasses.add( sp );
+				}
+			}
+			it = orderedFkSecondPasses.listIterator();
+			while ( it.hasNext() ) {
+				( (SecondPass) it.next() ).doSecondPass( classes );
+			}
+			it = endOfQueueFkSecondPasses.listIterator();
+			while ( it.hasNext() ) {
+				( (SecondPass) it.next() ).doSecondPass( classes );
+			}
+		}
+	}
+
 	private void processArtifactsOfType(String artifact) {
 		if ( "hbm".equalsIgnoreCase( artifact ) ) {
 			log.debug( "Process hbm files" );
@@ -485,7 +584,7 @@
 			}
 			else {
 				List<String> classnames = ( (JavaXFactory) reflectionManager ).getXMLContext().addDocument( doc );
-				for (String classname : classnames) {
+				for ( String classname : classnames ) {
 					try {
 						annotatedClasses.add( reflectionManager.classForName( classname, this.getClass() ) );
 					}
@@ -533,7 +632,7 @@
 		this.precedence = precedence;
 	}
 
-	private class CacheHolder {
+	private static class CacheHolder {
 		public CacheHolder(String role, String usage, String region, boolean isClass, boolean cacheLazy) {
 			this.role = role;
 			this.usage = usage;
@@ -558,8 +657,10 @@
 				saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true );
 				//saxReader.setFeature( "http://apache.org/xml/features/validation/dynamic", true );
 				//set the default schema locators
-				saxReader.setProperty( "http://apache.org/xml/properties/schema/external-schemaLocation",
-						"http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd");
+				saxReader.setProperty(
+						"http://apache.org/xml/properties/schema/external-schemaLocation",
+						"http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
+				);
 			}
 			catch (SAXException e) {
 				saxReader.setValidation( false );

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/BinderHelper.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/BinderHelper.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/BinderHelper.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -10,10 +10,13 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
+import java.util.Properties;
 
 import org.hibernate.AnnotationException;
 import org.hibernate.AssertionFailure;
 import org.hibernate.MappingException;
+import org.hibernate.id.PersistentIdentifierGenerator;
+import org.hibernate.id.MultipleHiLoPerTableGenerator;
 import org.hibernate.cfg.annotations.TableBinder;
 import org.hibernate.mapping.Collection;
 import org.hibernate.mapping.Column;
@@ -24,12 +27,17 @@
 import org.hibernate.mapping.Table;
 import org.hibernate.mapping.ToOne;
 import org.hibernate.mapping.Value;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.IdGenerator;
 import org.hibernate.util.StringHelper;
 
 /**
  * @author Emmanuel Bernard
  */
 public class BinderHelper {
+
+	public static final String ANNOTATION_STRING_DEFAULT = "";
+
 	private BinderHelper() {
 	}
 
@@ -247,13 +255,17 @@
 		return orderedProperties;
 	}
 
+	/**
+	 * Retrieve the property by path in a recursive way, including IndetifierProperty in the loop
+	 * If propertyName is null or empty, the IdentifierProperty is returned
+	 */
 	public static Property findPropertyByName(PersistentClass associatedClass, String propertyName) {
 		Property property = null;
 		Property idProperty = associatedClass.getIdentifierProperty();
 		String idName = idProperty != null ? idProperty.getName() : null;
 		try {
 			if ( propertyName == null
-					|| propertyName.equals( "" )
+					|| propertyName.length() == 0
 					|| propertyName.equals( idName ) ) {
 				//default to id
 				property = idProperty;
@@ -351,4 +363,57 @@
 		while ( !found && current != null );
 		return found ? result : null;
 	}
+
+	/** apply an id generator to a SimpleValue */
+	public static void makeIdGenerator(
+			SimpleValue id, String generatorType, String generatorName, ExtendedMappings mappings,
+			Map<String, IdGenerator> localGenerators
+	) {
+		Table table = id.getTable();
+		table.setIdentifierValue( id );
+		//generator settings
+		id.setIdentifierGeneratorStrategy( generatorType );
+		Properties params = new Properties();
+		//always settable
+		params.setProperty(
+				PersistentIdentifierGenerator.TABLE, table.getName()
+		);
+
+		if ( id.getColumnSpan() == 1 ) {
+			params.setProperty(
+					PersistentIdentifierGenerator.PK,
+					( (org.hibernate.mapping.Column) id.getColumnIterator().next() ).getName()
+			);
+		}
+		if ( ! isDefault( generatorName ) ) {
+			//we have a named generator
+			IdGenerator gen = mappings.getGenerator( generatorName, localGenerators );
+			if ( gen == null ) {
+				throw new AnnotationException( "Unknown Id.generator: " + generatorName );
+			}
+			//This is quite vague in the spec but a generator could override the generate choice
+			String identifierGeneratorStrategy = gen.getIdentifierGeneratorStrategy();
+			//yuk! this is a hack not to override 'AUTO' even if generator is set
+			final boolean avoidOverriding =
+					identifierGeneratorStrategy.equals( "identity" )
+							|| identifierGeneratorStrategy.equals( "seqhilo" )
+							|| identifierGeneratorStrategy.equals( MultipleHiLoPerTableGenerator.class.getName() );
+			if ( generatorType == null || ! avoidOverriding ) {
+				id.setIdentifierGeneratorStrategy( identifierGeneratorStrategy );
+			}
+			//checkIfMatchingGenerator(gen, generatorType, generatorName);
+			Iterator genParams = gen.getParams().entrySet().iterator();
+			while ( genParams.hasNext() ) {
+				Map.Entry elt = (Map.Entry) genParams.next();
+				params.setProperty( (String) elt.getKey(), (String) elt.getValue() );
+			}
+		}
+		if ( "assigned".equals( generatorType ) ) id.setNullValue( "undefined" );
+		id.setIdentifierGeneratorProperties( params );
+	}
+
+	public static boolean isDefault(String annotationString) {
+		return annotationString != null && annotationString.length() == 0;
+		//equivalent to (but faster) ANNOTATION_STRING_DEFAULT.equals( annotationString );
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ClassPropertyHolder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ClassPropertyHolder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ClassPropertyHolder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -94,6 +94,10 @@
 		return persistentClass.getClassName();
 	}
 
+	public String getEntityOwnerClassName() {
+		return getClassName();
+	}
+
 	public Table getTable() {
 		return persistentClass.getTable();
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/CollectionPropertyHolder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/CollectionPropertyHolder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/CollectionPropertyHolder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -21,9 +21,9 @@
 
 	public CollectionPropertyHolder(
 			Collection collection, String path, XClass clazzToProcess, XProperty property,
-			ExtendedMappings mappings
+			PropertyHolder parentPropertyHolder, ExtendedMappings mappings
 	) {
-		super( path, null, clazzToProcess, mappings );
+		super( path, parentPropertyHolder, clazzToProcess, mappings );
 		this.collection = collection;
 		setCurrentProperty( property );
 	}
@@ -32,6 +32,10 @@
 		throw new AssertionFailure( "Collection property holder does not have a class name" );
 	}
 
+	public String getEntityOwnerClassName() {
+		return null;
+	}
+
 	public Table getTable() {
 		return collection.getCollectionTable();
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ComponentPropertyHolder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ComponentPropertyHolder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ComponentPropertyHolder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -67,6 +67,10 @@
 		return component.getComponentClassName();
 	}
 
+	public String getEntityOwnerClassName() {
+		return component.getOwner().getClassName();
+	}
+
 	public Table getTable() {
 		return component.getTable();
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/CreateKeySecondPass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/CreateKeySecondPass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/CreateKeySecondPass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -22,7 +22,7 @@
 		this.joinedSubClass = joinedSubClass;
 	}
 
-	public void doSecondPass(Map persistentClasses, Map inheritedMetas) throws MappingException {
+	public void doSecondPass(Map persistentClasses) throws MappingException {
 		if ( rootClass != null ) {
 			rootClass.createPrimaryKey();
 		}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3Column.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3Column.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3Column.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -429,10 +429,16 @@
 		}
 	}
 
-	public void addIndex(Index index) {
+	public void addIndex(Index index, boolean inSecondPass) {
 		if ( index == null ) return;
-		mappings.addSecondPass(
-				new IndexSecondPass( index.name(), this, mappings )
-		);
+		IndexSecondPass secondPass = new IndexSecondPass( index.name(), this, mappings );
+		if (inSecondPass) {
+			secondPass.doSecondPass( mappings.getClasses() );
+		}
+		else {
+			mappings.addSecondPass(
+					secondPass
+			);
+		}
 	}
 }
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3DiscriminatorColumn.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3DiscriminatorColumn.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3DiscriminatorColumn.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -51,12 +51,12 @@
 		}
 		else if ( discAnn != null ) {
 			discriminatorColumn.setImplicit( false );
-			if ( ! AnnotationBinder.isDefault( discAnn.columnDefinition() ) ) {
+			if ( ! BinderHelper.isDefault( discAnn.columnDefinition() ) ) {
 				discriminatorColumn.setSqlType(
 						discAnn.columnDefinition()
 				);
 			}
-			if ( ! AnnotationBinder.isDefault( discAnn.name() ) ) {
+			if ( ! BinderHelper.isDefault( discAnn.name() ) ) {
 				discriminatorColumn.setLogicalColumnName( discAnn.name() );
 			}
 			discriminatorColumn.setNullable( false );

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3JoinColumn.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3JoinColumn.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/Ejb3JoinColumn.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -61,7 +61,7 @@
 
 	//Due to @AnnotationOverride overriding rules, I don't want the constructor to be public
 	private Ejb3JoinColumn() {
-		setMappedBy( AnnotationBinder.ANNOTATION_STRING_DEFAULT );
+		setMappedBy( BinderHelper.ANNOTATION_STRING_DEFAULT );
 	}
 
 	//Due to @AnnotationOverride overriding rules, I don't want the constructor to be public
@@ -148,7 +148,7 @@
 			ExtendedMappings mappings
 	) {
 		if ( ann != null ) {
-			if ( AnnotationBinder.isDefault( mappedBy ) ) {
+			if ( BinderHelper.isDefault( mappedBy ) ) {
 				throw new AnnotationException(
 						"Illegal attempt to define a @JoinColumn with a mappedBy association: "
 								+ BinderHelper.getRelativePath( propertyHolder, propertyName )
@@ -185,8 +185,8 @@
 		}
 		else {
 			setImplicit( false );
-			if ( ! AnnotationBinder.isDefault( annJoin.columnDefinition() ) ) setSqlType( annJoin.columnDefinition() );
-			if ( ! AnnotationBinder.isDefault( annJoin.name() ) ) setLogicalColumnName( annJoin.name() );
+			if ( ! BinderHelper.isDefault( annJoin.columnDefinition() ) ) setSqlType( annJoin.columnDefinition() );
+			if ( ! BinderHelper.isDefault( annJoin.name() ) ) setLogicalColumnName( annJoin.name() );
 			setNullable( annJoin.nullable() );
 			setUnique( annJoin.unique() );
 			setInsertable( annJoin.insertable() );

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ExtendedMappings.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ExtendedMappings.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/ExtendedMappings.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -259,4 +259,8 @@
 	public void addSQLQuery(String name, NamedSQLQueryDefinition query) throws MappingException {
 		if ( ! defaultNamedNativeQueryNames.contains( name ) ) super.addSQLQuery( name, query );
 	}
+
+	public Map getClasses() {
+		return classes;
+	}
 }
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/FkSecondPass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/FkSecondPass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/FkSecondPass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -4,11 +4,13 @@
 import org.hibernate.AnnotationException;
 import org.hibernate.AssertionFailure;
 import org.hibernate.MappingException;
+import org.hibernate.util.StringHelper;
 import org.hibernate.cfg.annotations.TableBinder;
 import org.hibernate.mapping.ManyToOne;
 import org.hibernate.mapping.OneToOne;
 import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Value;
+import org.hibernate.mapping.ToOne;
+import org.hibernate.mapping.Property;
 
 /**
  * Enable a proper set of the FK columns in respect with the id column order
@@ -18,27 +20,44 @@
  * @author Emmanuel Bernard
  */
 public class FkSecondPass implements SecondPass {
-	private Value value;
+	private ToOne value;
 	private Ejb3JoinColumn[] columns;
 	private boolean unique;
 	private ExtendedMappings mappings;
 	private String path;
+	private String entityClassName;
 
-	FkSecondPass(Value value, Ejb3JoinColumn[] columns, boolean unique, String path, ExtendedMappings mappings) {
+	FkSecondPass(
+			ToOne value, Ejb3JoinColumn[] columns, boolean unique, String entityClassName, String path, ExtendedMappings mappings
+	) {
 		this.mappings = mappings;
 		this.value = value;
 		this.columns = columns;
 		this.unique = unique;
-		this.path = path;
+		this.entityClassName = entityClassName;
+		this.path = entityClassName != null ? path.substring( entityClassName.length() + 1 ) : path;
 	}
 
-	public void doSecondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas) throws MappingException {
+	public ToOne getValue() {
+		return value;
+	}
+
+	public boolean isInPrimaryKey() {
+		if (entityClassName == null) return false;
+		Property property = mappings.getClass( entityClassName ).getIdentifierProperty();
+		return property != null && path != null && path.startsWith( property.getName() );
+	}
+
+	public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
 		if ( value instanceof ManyToOne ) {
 			ManyToOne manyToOne = (ManyToOne) value;
 			PersistentClass ref = (PersistentClass) persistentClasses.get( manyToOne.getReferencedEntityName() );
 			if ( ref == null ) {
 				throw new AnnotationException(
-						"@OneToOne or @ManyToOne on " + path + " references an unknown entity: " + manyToOne.getReferencedEntityName()
+						"@OneToOne or @ManyToOne on "
+								+ StringHelper.qualify(entityClassName, path)
+								+ " references an unknown entity: "
+								+ manyToOne.getReferencedEntityName()
 				);
 			}
 			BinderHelper.createSyntheticPropertyReference( columns, ref, null, manyToOne, false, mappings );

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/IndexColumn.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/IndexColumn.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/IndexColumn.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -67,8 +67,8 @@
 	) {
 		IndexColumn column;
 		if ( ann != null ) {
-			String sqlType = AnnotationBinder.isDefault( ann.columnDefinition() ) ? null : ann.columnDefinition();
-			String name = AnnotationBinder.isDefault( ann.name() ) ? inferredData.getPropertyName() : ann.name();
+			String sqlType = BinderHelper.isDefault( ann.columnDefinition() ) ? null : ann.columnDefinition();
+			String name = BinderHelper.isDefault( ann.name() ) ? inferredData.getPropertyName() : ann.name();
 			//TODO move it to a getter based system and remove the constructor
 			column = new IndexColumn(
 					false, sqlType, 0, 0, 0, name, ann.nullable(),

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/IndexSecondPass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/IndexSecondPass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/IndexSecondPass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -33,7 +33,7 @@
 		this.mappings = mappings;
 	}
 
-	public void doSecondPass(Map persistentClasses, Map inheritedMetas) throws MappingException {
+	public void doSecondPass(Map persistentClasses) throws MappingException {
 		if ( columns != null ) {
 			for ( String columnName : columns ) {
 				addIndexToColumn( columnName );

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/OneToOneSecondPass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/OneToOneSecondPass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/OneToOneSecondPass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -6,6 +6,7 @@
 
 import org.hibernate.AnnotationException;
 import org.hibernate.MappingException;
+import org.hibernate.annotations.ForeignKey;
 import org.hibernate.cfg.annotations.PropertyBinder;
 import org.hibernate.mapping.Column;
 import org.hibernate.mapping.DependantValue;
@@ -59,7 +60,7 @@
 	}
 
 	//TODO refactor this code, there is a lot of duplication in this method
-	public void doSecondPass(Map persistentClasses, Map inheritedMetas) throws MappingException {
+	public void doSecondPass(Map persistentClasses) throws MappingException {
 		org.hibernate.mapping.OneToOne value = new org.hibernate.mapping.OneToOne(
 				propertyHolder.getTable(), propertyHolder.getPersistentClass()
 		);
@@ -90,7 +91,7 @@
 		binder.setCascade( cascadeStrategy );
 		binder.setPropertyAccessorName( inferredData.getDefaultAccess() );
 		Property prop = binder.make();
-		if ( AnnotationBinder.isDefault( mappedBy ) ) {
+		if ( BinderHelper.isDefault( mappedBy ) ) {
 			/*
 			 * we need to check if the columns are in the right order
 			 * if not, then we need to create a many to one and formula
@@ -104,8 +105,9 @@
 				( new FkSecondPass(
 						value, joinColumns,
 						!optional, //cannot have nullabe and unique on certain DBs
+						propertyHolder.getEntityOwnerClassName(),
 						path, mappings
-				) ).doSecondPass( persistentClasses, inheritedMetas );
+				) ).doSecondPass( persistentClasses );
 				//no column associated since its a one to one
 				propertyHolder.addProperty( prop );
 			}
@@ -121,7 +123,7 @@
 				if ( otherSide == null ) {
 					throw new MappingException( "Unable to find entity: " + value.getReferencedEntityName() );
 				}
-				otherSideProperty = otherSide.getProperty( mappedBy );
+				otherSideProperty = BinderHelper.findPropertyByName( otherSide, mappedBy );
 			}
 			catch (MappingException e) {
 				throw new AnnotationException(
@@ -201,6 +203,9 @@
 				);
 			}
 		}
+		ForeignKey fk = inferredData.getProperty().getAnnotation( ForeignKey.class );
+		String fkName = fk != null ? fk.name() : "";
+		if ( ! BinderHelper.isDefault( fkName ) ) value.setForeignKeyName( fkName );
 	}
 
 	//dirty dupe of EntityBinder.bindSecondaryTable

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/PropertyHolder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/PropertyHolder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/PropertyHolder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -18,6 +18,8 @@
 public interface PropertyHolder {
 	String getClassName();
 
+	String getEntityOwnerClassName();
+
 	Table getTable();
 
 	void addProperty(Property prop);

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/PropertyHolderBuilder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/PropertyHolderBuilder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/PropertyHolderBuilder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -50,9 +50,9 @@
 	 */
 	public static PropertyHolder buildPropertyHolder(
 			Collection collection, String path, XClass clazzToProcess, XProperty property,
-			ExtendedMappings mappings
+			PropertyHolder parentPropertyHolder, ExtendedMappings mappings
 	) {
-		return new CollectionPropertyHolder( collection, path, clazzToProcess, property, mappings );
+		return new CollectionPropertyHolder( collection, path, clazzToProcess, property, parentPropertyHolder, mappings );
 	}
 
 	/**

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -22,17 +22,23 @@
 import org.hibernate.AssertionFailure;
 import org.hibernate.FetchMode;
 import org.hibernate.MappingException;
-import org.hibernate.annotations.AccessType;
 import org.hibernate.annotations.BatchSize;
 import org.hibernate.annotations.Cache;
+import org.hibernate.annotations.CollectionId;
 import org.hibernate.annotations.CollectionOfElements;
 import org.hibernate.annotations.Fetch;
+import org.hibernate.annotations.Filter;
+import org.hibernate.annotations.FilterJoinTable;
+import org.hibernate.annotations.FilterJoinTables;
+import org.hibernate.annotations.Filters;
+import org.hibernate.annotations.ForeignKey;
 import org.hibernate.annotations.LazyCollection;
 import org.hibernate.annotations.LazyCollectionOption;
 import org.hibernate.annotations.OrderBy;
 import org.hibernate.annotations.Sort;
 import org.hibernate.annotations.SortType;
 import org.hibernate.annotations.Where;
+import org.hibernate.annotations.WhereJoinTable;
 import org.hibernate.cfg.AnnotatedClassType;
 import org.hibernate.cfg.AnnotationBinder;
 import org.hibernate.cfg.BinderHelper;
@@ -51,24 +57,24 @@
 import org.hibernate.mapping.Column;
 import org.hibernate.mapping.Component;
 import org.hibernate.mapping.DependantValue;
+import org.hibernate.mapping.IdGenerator;
 import org.hibernate.mapping.Join;
 import org.hibernate.mapping.KeyValue;
 import org.hibernate.mapping.ManyToOne;
 import org.hibernate.mapping.PersistentClass;
 import org.hibernate.mapping.Property;
+import org.hibernate.mapping.Selectable;
 import org.hibernate.mapping.SimpleValue;
 import org.hibernate.mapping.Table;
-import org.hibernate.reflection.XAnnotatedElement;
 import org.hibernate.reflection.XClass;
 import org.hibernate.reflection.XProperty;
-import org.hibernate.util.CollectionHelper;
 import org.hibernate.util.StringHelper;
 
 /**
  * Collection binder
  *
  * @author inger
- * @author emmanuel
+ * @author Emmanuel Bernard
  */
 public abstract class CollectionBinder {
 
@@ -78,7 +84,6 @@
 	protected String propertyName;
 	PropertyHolder propertyHolder;
 	int batchSize;
-	String where;
 	private String mappedBy;
 	private XClass collectionType;
 	private XClass targetEntity;
@@ -86,7 +91,6 @@
 	private Ejb3JoinColumn[] inverseJoinColumns;
 	private String cascadeStrategy;
 	String cacheConcurrencyStrategy;
-	Map<String, String> filters = new HashMap<String, String>();
 	String cacheRegionName;
 	private boolean oneToMany;
 	protected IndexColumn indexColumn;
@@ -108,6 +112,7 @@
 	private TableBinder tableBinder;
 	private Ejb3Column[] mapKeyColumns;
 	private Ejb3JoinColumn[] mapKeyManyToManyColumns;
+	protected HashMap<String, IdGenerator> localGenerators;
 
 	public void setUpdatable(boolean updatable) {
 		this.updatable = updatable;
@@ -154,7 +159,7 @@
 
 	public void setSqlOrderBy(OrderBy orderByAnn) {
 		if ( orderByAnn != null ) {
-			if ( ! AnnotationBinder.isDefault( orderByAnn.clause() ) ) orderBy = orderByAnn.clause();
+			if ( ! BinderHelper.isDefault( orderByAnn.clause() ) ) orderBy = orderByAnn.clause();
 		}
 	}
 
@@ -171,10 +176,9 @@
 	 * collection binder factory
 	 */
 	public static CollectionBinder getCollectionBinder(
-			String entityName, PropertyData inferredData,
+			String entityName, XProperty property,
 			boolean isIndexed
 	) {
-		XProperty property = inferredData.getProperty();
 		if ( property.isArray() ) {
 			if ( property.getElementClass().isPrimitive() ) {
 				return new PrimitiveArrayBinder();
@@ -195,13 +199,24 @@
 			else if ( java.util.Map.class.equals( returnedClass ) ) {
 				return new MapBinder();
 			}
+			else if ( java.util.SortedMap.class.equals( returnedClass ) ) {
+				return new MapBinder(true);
+			}
 			else if ( java.util.Collection.class.equals( returnedClass ) ) {
-				return new BagBinder();
+				if ( property.isAnnotationPresent( CollectionId.class ) ) {
+					return new IdBagBinder();
+				}
+				else {
+					return new BagBinder();
+				}
 			}
 			else if ( java.util.List.class.equals( returnedClass ) ) {
 				if ( isIndexed ) {
 					return new ListBinder();
 				}
+				else if ( property.isAnnotationPresent( CollectionId.class ) ) {
+					return new IdBagBinder();
+				}
 				else {
 					return new BagBinder();
 				}
@@ -291,6 +306,12 @@
 				try {
 					collection.setComparator( (Comparator) comparator.newInstance() );
 				}
+				catch (ClassCastException e) {
+					throw new AnnotationException(
+							"Comparator not implementing java.util.Comparator class: "
+									+ comparator.getName() + "(" + safeCollectionRole() + ")"
+					);
+				}
 				catch (Exception e) {
 					throw new AnnotationException(
 							"Could not instantiate comparator class: "
@@ -314,27 +335,8 @@
 			collection.setCacheRegionName( cacheRegionName );
 		}
 
-		//set filtering
-		Iterator<Map.Entry<String, String>> iter = filters.entrySet().iterator();
-		if ( StringHelper.isNotEmpty( where ) ) collection.setWhere( where );
-		while ( iter.hasNext() ) {
-			Map.Entry<String, String> filter = iter.next();
-			String name = filter.getKey();
-			String cond = filter.getValue();
-			if ( AnnotationBinder.isDefault( cond ) ) {
-				cond = mappings.getFilterDefinition( name ).getDefaultFilterCondition();
-				if ( StringHelper.isEmpty( cond ) ) {
-					throw new AnnotationException(
-							"no filter condition found for filter " + name + " in "
-									+ StringHelper.qualify( propertyHolder.getPath(), propertyName )
-					);
-				}
-			}
-			collection.addFilter( name, cond );
-		}
-
 		//work on association
-		boolean isMappedBy = ! AnnotationBinder.isDefault( mappedBy );
+		boolean isMappedBy = ! BinderHelper.isDefault( mappedBy );
 		collection.setInverse( isMappedBy );
 		String collType = getCollectionType().getName();
 
@@ -359,7 +361,8 @@
 				|| property.isAnnotationPresent( CollectionOfElements.class ) ) {
 			// do it right away, otherwise @ManyToon on composite element call addSecondPass 
 			// and raise a ConcurrentModificationException
-			sp.doSecondPass( CollectionHelper.EMPTY_MAP, CollectionHelper.EMPTY_MAP );
+			//sp.doSecondPass( CollectionHelper.EMPTY_MAP );
+			mappings.addSecondPass( sp, ! isMappedBy );
 		}
 		else {
 			mappings.addSecondPass( sp, ! isMappedBy );
@@ -494,7 +497,7 @@
 			}
 			catch (MappingException e) {
 				StringBuilder error = new StringBuilder( 80 );
-				error.append( "mappedBy reference an unknown property: " )
+				error.append( "mappedBy reference an unknown target entity property: " )
 						.append( collType ).append( "." ).append( this.mappedBy )
 						.append( " in " )
 						.append( collection.getOwnerEntityName() )
@@ -507,7 +510,7 @@
 				&& ! reversePropertyInJoin
 				&& oneToMany
 				&& ! this.isExplicitAssociationTable
-				&& ( joinColumns[0].isImplicit() && ! AnnotationBinder.isDefault( this.mappedBy ) //implicit @JoinColumn
+				&& ( joinColumns[0].isImplicit() && ! BinderHelper.isDefault( this.mappedBy ) //implicit @JoinColumn
 				|| ! fkJoinColumns[0].isImplicit() ) //this is an explicit @JoinColumn
 				) {
 			//this is a Foreign key
@@ -533,7 +536,7 @@
 					isEmbedded, collType,
 					ignoreNotFound, unique,
 					cascadeDeleteEnabled,
-					associationTableBinder, property, hqlOrderBy, mappings
+					associationTableBinder, property, propertyHolder, hqlOrderBy, mappings
 			);
 			return false;
 		}
@@ -578,8 +581,8 @@
 		log.info(
 				"Mapping collection: " + collection.getRole() + " -> " + collection.getCollectionTable().getName()
 		);
-
-		bindCollectionSecondPass( collection, null, fkJoinColumns, cascadeDeleteEnabled, mappings );
+		bindFilters(false);
+		bindCollectionSecondPass( collection, null, fkJoinColumns, cascadeDeleteEnabled, property, mappings );
 		if ( !collection.isInverse()
 				&& !collection.getKey().isNullable() ) {
 			// for non-inverse one-to-many, with a not-null fk, add a backref!
@@ -596,9 +599,122 @@
 		}
 	}
 
+	private void bindFilters(boolean hasAssociationTable) {
+		Filter simpleFilter = property.getAnnotation( Filter.class );
+		//set filtering
+		//test incompatible choices
+		//if ( StringHelper.isNotEmpty( where ) ) collection.setWhere( where );
+		if (simpleFilter != null) {
+			if (hasAssociationTable) {
+				collection.addManyToManyFilter( simpleFilter.name(), getCondition( simpleFilter ) );
+			}
+			else {
+				collection.addFilter( simpleFilter.name(), getCondition( simpleFilter ) );
+			}
+		}
+		Filters filters = property.getAnnotation( Filters.class );
+		if (filters != null) {
+			for ( Filter filter : filters.value() ) {
+				if (hasAssociationTable) {
+					collection.addManyToManyFilter( filter.name(), getCondition( filter ) );
+				}
+				else {
+					collection.addFilter( filter.name(), getCondition( filter ) );
+				}
+			}
+		}
+		FilterJoinTable simpleFilterJoinTable = property.getAnnotation( FilterJoinTable.class );
+		if (simpleFilterJoinTable != null) {
+			if (hasAssociationTable) {
+				collection.addFilter( simpleFilterJoinTable.name(), getCondition( simpleFilterJoinTable ) );
+			}
+			else {
+				throw new AnnotationException(
+						"Illegal use of @FilterJoinTable on an association without join table:"
+								+ StringHelper.qualify( propertyHolder.getPath(), propertyName )
+				);
+			}
+		}
+		FilterJoinTables filterJoinTables = property.getAnnotation( FilterJoinTables.class );
+		if (filterJoinTables != null) {
+			for ( FilterJoinTable filter : filterJoinTables.value() ) {
+				if (hasAssociationTable) {
+					collection.addFilter( filter.name(), getCondition( filter ) );
+				}
+				else {
+					throw new AnnotationException(
+							"Illegal use of @FilterJoinTable on an association without join table:"
+									+ StringHelper.qualify( propertyHolder.getPath(), propertyName )
+					);
+				}
+			}
+		}
+
+		Where where = property.getAnnotation( Where.class );
+		String whereClause = where == null ? null : where.clause();
+		if ( StringHelper.isNotEmpty( whereClause ) ) {
+			if (hasAssociationTable) {
+				collection.setManyToManyWhere( whereClause );
+			}
+			else {
+				collection.setWhere( whereClause );
+			}
+		}
+
+		WhereJoinTable whereJoinTable = property.getAnnotation( WhereJoinTable.class );
+		String whereJoinTableClause = whereJoinTable == null ? null : whereJoinTable.clause();
+		if ( StringHelper.isNotEmpty( whereJoinTableClause ) ) {
+			if (hasAssociationTable) {
+				collection.setWhere( whereJoinTableClause );
+			}
+			else {
+				throw new AnnotationException(
+						"Illegal use of @WhereJoinTable on an association without join table:"
+								+ StringHelper.qualify( propertyHolder.getPath(), propertyName )
+				);
+			}
+		}
+//		This cannot happen in annotations since the second fetch is hardcoded to join
+//		if ( ( ! collection.getManyToManyFilterMap().isEmpty() || collection.getManyToManyWhere() != null ) &&
+//		        collection.getFetchMode() == FetchMode.JOIN &&
+//		        collection.getElement().getFetchMode() != FetchMode.JOIN ) {
+//			throw new MappingException(
+//			        "association with join table  defining filter or where without join fetching " +
+//			        "not valid within collection using join fetching [" + collection.getRole() + "]"
+//				);
+//		}
+	}
+
+	private String getCondition(FilterJoinTable filter) {
+		//set filtering
+		String name = filter.name();
+		String cond = filter.condition();
+		return getCondition( cond, name );
+	}
+
+	private String getCondition(Filter filter) {
+		//set filtering
+		String name = filter.name();
+		String cond = filter.condition();
+		return getCondition( cond, name );
+	}
+
+	private String getCondition(String cond, String name) {
+		if ( BinderHelper.isDefault( cond ) ) {
+			cond = mappings.getFilterDefinition( name ).getDefaultFilterCondition();
+			if ( StringHelper.isEmpty( cond ) ) {
+				throw new AnnotationException(
+						"no filter condition found for filter " + name + " in "
+								+ StringHelper.qualify( propertyHolder.getPath(), propertyName )
+				);
+			}
+		}
+		return cond;
+	}
+
 	public void setCache(Cache cacheAnn) {
 		if ( cacheAnn != null ) {
-			cacheRegionName = AnnotationBinder.isDefault( cacheAnn.region() ) ? null : cacheAnn.region();
+			cacheRegionName = BinderHelper.isDefault( cacheAnn.region() ) ? null : cacheAnn.region();
 			cacheConcurrencyStrategy = EntityBinder.getCacheConcurrencyStrategy( cacheAnn.usage() );
 		}
 		else {
@@ -607,16 +723,6 @@
 		}
 	}
 
-	public void addFilter(String name, String condition) {
-		filters.put( name, condition );
-	}
-
-	public void setWhere(Where whereAnn) {
-		if ( whereAnn != null ) {
-			where = whereAnn.clause();
-		}
-	}
-
 	public void setOneToMany(boolean oneToMany) {
 		this.oneToMany = oneToMany;
 	}
@@ -637,12 +743,12 @@
 			List<String> properties = new ArrayList<String>();
 			List<String> ordering = new ArrayList<String>();
 			StringBuilder orderByBuffer = new StringBuilder();
-			if ( "".equals( hqlOrderBy ) ) {
+			if ( hqlOrderBy.length() == 0 ) {
 				//order by id
 				Iterator it = associatedClass.getIdentifier().getColumnIterator();
 				while ( it.hasNext() ) {
-					Column col = (Column) it.next();
-					orderByBuffer.append( col.getName() ).append( " asc" ).append( ", " );
+					Selectable col = (Selectable) it.next();
+					orderByBuffer.append( col.getText() ).append( " asc" ).append( ", " );
 				}
 			}
 			else {
@@ -696,8 +802,8 @@
 
 					Iterator propertyColumns = p.getColumnIterator();
 					while ( propertyColumns.hasNext() ) {
-						Column column = (Column) propertyColumns.next();
-						orderByBuffer.append( column.getName() )
+						Selectable column = (Selectable) propertyColumns.next();
+						orderByBuffer.append( column.getText() )
 								.append( " " )
 								.append( ordering.get( index ) )
 								.append( ", " );
@@ -716,7 +822,7 @@
 			List<String> properties = new ArrayList<String>();
 			List<String> ordering = new ArrayList<String>();
 			StringBuilder orderByBuffer = new StringBuilder();
-			if ( "".equals( hqlOrderBy ) ) {
+			if ( hqlOrderBy.length() == 0 ) {
 				//TODO : Check that. Maybe order by key for maps
 			}
 			else {
@@ -770,8 +876,8 @@
 
 					Iterator propertyColumns = p.getColumnIterator();
 					while ( propertyColumns.hasNext() ) {
-						Column column = (Column) propertyColumns.next();
-						orderByBuffer.append( column.getName() )
+						Selectable column = (Selectable) propertyColumns.next();
+						orderByBuffer.append( column.getText() )
 								.append( " " )
 								.append( ordering.get( index ) )
 								.append( ", " );
@@ -797,7 +903,7 @@
 
 	private static SimpleValue buildCollectionKey(
 			Collection collValue, Ejb3JoinColumn[] joinColumns, boolean cascadeDeleteEnabled,
-			ExtendedMappings mappings
+			XProperty property, ExtendedMappings mappings
 	) {
 		//binding key reference using column
 		KeyValue keyVal;
@@ -822,20 +928,23 @@
 		}
 		else {
 			keyVal = (KeyValue) collValue.getOwner()
-					.getProperty( propRef )
+					.getRecursiveProperty( propRef )
 					.getValue();
 		}
 		DependantValue key = new DependantValue( collValue.getCollectionTable(), keyVal );
 		key.setTypeName( null );
-		Ejb3JoinColumn.checkPropertyConsistency( joinColumns, collValue.getOwnerEntityName() );
+		Ejb3Column.checkPropertyConsistency( joinColumns, collValue.getOwnerEntityName() );
 		key.setNullable( joinColumns.length == 0 || joinColumns[0].isNullable() );
 		key.setUpdateable( joinColumns.length == 0 || joinColumns[0].isUpdatable() );
 		key.setCascadeDeleteEnabled( cascadeDeleteEnabled );
 		collValue.setKey( key );
+		ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null;
+		String fkName = fk != null ? fk.name() : "";
+		if ( ! BinderHelper.isDefault( fkName ) ) key.setForeignKeyName( fkName );
 		return key;
 	}
 
-	protected static void bindManyToManySecondPass(
+	protected void bindManyToManySecondPass(
 			Collection collValue,
 			Map persistentClasses,
 			Ejb3JoinColumn[] joinColumns,
@@ -845,7 +954,8 @@
 			String collType,
 			boolean ignoreNotFound, boolean unique,
 			boolean cascadeDeleteEnabled,
-			TableBinder associationTableBinder, XProperty property, String hqlOrderBy, ExtendedMappings mappings
+			TableBinder associationTableBinder, XProperty property, PropertyHolder parentPropertyHolder,
+			String hqlOrderBy, ExtendedMappings mappings
 	) throws MappingException {
 
 		PersistentClass collectionEntity = (PersistentClass) persistentClasses.get( collType );
@@ -881,7 +991,7 @@
 			}
 		}
 
-		boolean mappedBy = ! AnnotationBinder.isDefault( joinColumns[0].getMappedBy() );
+		boolean mappedBy = ! BinderHelper.isDefault( joinColumns[0].getMappedBy() );
 		if ( mappedBy ) {
 			if ( ! isCollectionOfEntities ) {
 				StringBuilder error = new StringBuilder( 80 )
@@ -895,11 +1005,11 @@
 			}
 			Property otherSideProperty;
 			try {
-				otherSideProperty = collectionEntity.getProperty( joinColumns[0].getMappedBy() );
+				otherSideProperty = collectionEntity.getRecursiveProperty( joinColumns[0].getMappedBy() );
 			}
 			catch (MappingException e) {
 				StringBuilder error = new StringBuilder( 80 );
-				error.append( "mappedBy reference an unknown property: " )
+				error.append( "mappedBy reference an unknown target entity property: " )
 						.append( collType ).append( "." ).append( joinColumns[0].getMappedBy() )
 						.append( " in " )
 						.append( collValue.getOwnerEntityName() )
@@ -950,9 +1060,9 @@
 			}
 			collValue.setCollectionTable( associationTableBinder.bind() );
 		}
+		bindFilters( isCollectionOfEntities );
+		bindCollectionSecondPass( collValue, collectionEntity, joinColumns, cascadeDeleteEnabled, property, mappings );
 
-		bindCollectionSecondPass( collValue, collectionEntity, joinColumns, cascadeDeleteEnabled, mappings );
-
 		ManyToOne element = null;
 		if ( isCollectionOfEntities ) {
 			element =
@@ -970,6 +1080,9 @@
 						buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() )
 				);
 			}
+			ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null;
+			String fkName = fk != null ? fk.inverseName() : "";
+			if ( ! BinderHelper.isDefault( fkName ) ) element.setForeignKeyName( fkName );
 		}
 		else {
 			XClass elementClass;
@@ -996,7 +1109,7 @@
 						collValue,
 						collValue.getRole(), // + ".element",
 						elementClass,
-						property, mappings
+						property, parentPropertyHolder, mappings
 				);
 				//force in case of attribute override
 				boolean attributeOverride = property.isAnnotationPresent( AttributeOverride.class )
@@ -1008,10 +1121,8 @@
 
 			if ( AnnotatedClassType.EMBEDDABLE.equals( classType ) ) {
 				EntityBinder entityBinder = new EntityBinder();
-				Embeddable embeddable = (Embeddable) elementClass.getAnnotation( Embeddable.class );
 				PersistentClass owner = collValue.getOwner();
 				boolean isPropertyAnnotated;
-				AccessType access = ( (XAnnotatedElement) elementClass ).getAnnotation( AccessType.class );
 				//FIXME support @Access for collection of elements
 				//String accessType = access != null ? access.value() : null;
 				if ( owner.getIdentifierProperty() != null ) {
@@ -1031,7 +1142,7 @@
 				Component component = AnnotationBinder.fillComponent(
 						holder, inferredData, isPropertyAnnotated, isPropertyAnnotated ? "property" : "field", true,
 						entityBinder, false, false,
-						mappings
+						true, mappings
 				);
 
 				collValue.setElement( component );
@@ -1087,7 +1198,7 @@
 				collValue.getFetchMode() == FetchMode.JOIN &&
 				collValue.getElement().getFetchMode() != FetchMode.JOIN ) {
 			throw new MappingException(
-					"@ManyToMany defining filter or where without join fetching "
+					"@ManyToMany or @CollectionOfElements defining filter or where without join fetching "
 							+ "not valid within collection using join fetching[" + collValue.getRole() + "]"
 			);
 		}
@@ -1095,13 +1206,13 @@
 
 	private static void bindCollectionSecondPass(
 			Collection collValue, PersistentClass collectionEntity, Ejb3JoinColumn[] joinColumns,
-			boolean cascadeDeleteEnabled,
+			boolean cascadeDeleteEnabled, XProperty property,
 			ExtendedMappings mappings
 	) {
 		BinderHelper.createSyntheticPropertyReference(
 				joinColumns, collValue.getOwner(), collectionEntity, collValue, false, mappings
 		);
-		SimpleValue key = buildCollectionKey( collValue, joinColumns, cascadeDeleteEnabled, mappings );
+		SimpleValue key = buildCollectionKey( collValue, joinColumns, cascadeDeleteEnabled, property, mappings );
 		TableBinder.bindFk( collValue.getOwner(), collectionEntity, joinColumns, key, false, mappings );
 	}
 
@@ -1131,7 +1242,7 @@
 	) {
 		final String mappedBy = columns[0].getMappedBy();
 		if ( StringHelper.isNotEmpty( mappedBy ) ) {
-			final Property property = referencedEntity.getProperty( mappedBy );
+			final Property property = referencedEntity.getRecursiveProperty( mappedBy );
 			Iterator mappedByColumns;
 			if ( property.getValue() instanceof Collection ) {
 				mappedByColumns = ( (Collection) property.getValue() ).getKey().getColumnIterator();
@@ -1202,4 +1313,8 @@
 	public void setMapKeyManyToManyColumns(Ejb3JoinColumn[] mapJoinColumns) {
 		this.mapKeyManyToManyColumns = mapJoinColumns;
 	}
+
+	public void setLocalGenerators(HashMap<String, IdGenerator> localGenerators) {
+		this.localGenerators = localGenerators;
+	}
 }
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -28,12 +28,14 @@
 import org.hibernate.annotations.Proxy;
 import org.hibernate.annotations.Tables;
 import org.hibernate.annotations.Where;
+import org.hibernate.annotations.ForceDiscriminator;
 import org.hibernate.cache.CacheFactory;
 import org.hibernate.cfg.AnnotationBinder;
 import org.hibernate.cfg.Ejb3JoinColumn;
 import org.hibernate.cfg.ExtendedMappings;
 import org.hibernate.cfg.InheritanceState;
 import org.hibernate.cfg.PropertyHolder;
+import org.hibernate.cfg.BinderHelper;
 import org.hibernate.engine.Versioning;
 import org.hibernate.mapping.DependantValue;
 import org.hibernate.mapping.Join;
@@ -130,7 +132,7 @@
 
 	private void bindEjb3Annotation(Entity ejb3Ann) {
 		if ( ejb3Ann == null ) throw new AssertionFailure( "@Entity should always be not null" );
-		if ( AnnotationBinder.isDefault( ejb3Ann.name() ) ) {
+		if ( BinderHelper.isDefault( ejb3Ann.name() ) ) {
 			name = StringHelper.unqualify( annotatedClass.getName() );
 		}
 		else {
@@ -165,6 +167,7 @@
 				rootClass.setCacheRegionName( cacheRegion );
 				rootClass.setLazyPropertiesCacheable( cacheLazyProperty );
 			}
+			rootClass.setForceDiscriminator( annotatedClass.isAnnotationPresent( ForceDiscriminator.class ) );
 		}
 		else {
 			if (explicitHibernateEntityAnnotation) {
@@ -174,7 +177,7 @@
 		}
 		persistentClass.setOptimisticLockMode( getVersioning( optimisticLockType ) );
 		persistentClass.setSelectBeforeUpdate( selectBeforeUpdate );
-		if ( ! AnnotationBinder.isDefault( persister ) ) {
+		if ( ! BinderHelper.isDefault( persister ) ) {
 			try {
 				persistentClass.setEntityPersisterClass( ReflectHelper.classForName( persister ) );
 			}
@@ -190,7 +193,7 @@
 				Map.Entry<String, String> filter = iter.next();
 				String filterName = filter.getKey();
 				String cond = filter.getValue();
-				if ( AnnotationBinder.isDefault( cond ) ) {
+				if ( BinderHelper.isDefault( cond ) ) {
 					cond = mappings.getFilterDefinition( filterName ).getDefaultFilterCondition();
 					if ( StringHelper.isEmpty( cond ) ) {
 						throw new AnnotationException(
@@ -538,7 +541,7 @@
 
 	public void setCache(Cache cacheAnn) {
 		if ( cacheAnn != null ) {
-			cacheRegion = AnnotationBinder.isDefault( cacheAnn.region() ) ? null : cacheAnn.region();
+			cacheRegion = BinderHelper.isDefault( cacheAnn.region() ) ? null : cacheAnn.region();
 			cacheConcurrentStrategy = getCacheConcurrencyStrategy( cacheAnn.usage() );
 			if ( "all".equalsIgnoreCase( cacheAnn.include() ) ) {
 				cacheLazyProperty = true;

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/IdBagBinder.java (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/IdBagBinder.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ListBinder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ListBinder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ListBinder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -6,6 +6,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.AnnotationException;
 import org.hibernate.MappingException;
+import org.hibernate.util.StringHelper;
 import org.hibernate.annotations.OrderBy;
 import org.hibernate.annotations.Sort;
 import org.hibernate.cfg.CollectionSecondPass;
@@ -74,9 +75,9 @@
 		if ( indexColumn.isImplicit() == false ) {
 			PropertyHolder valueHolder = PropertyHolderBuilder.buildPropertyHolder(
 					this.collection,
-					this.collection.getRole() + "key",
+					StringHelper.qualify( this.collection.getRole(), "key" ),
 					(XClass) null,
-					(XProperty) null, mappings
+					(XProperty) null, propertyHolder, mappings
 			);
 			List list = (List) this.collection;
 			if ( ! list.isOneToMany() ) indexColumn.forceNotNull();

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/MapBinder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/MapBinder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/MapBinder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -7,16 +7,11 @@
 import java.util.Random;
 import javax.persistence.AttributeOverride;
 import javax.persistence.AttributeOverrides;
-import javax.persistence.Embeddable;
 
 import org.hibernate.AnnotationException;
 import org.hibernate.AssertionFailure;
 import org.hibernate.FetchMode;
 import org.hibernate.MappingException;
-import org.hibernate.dialect.HSQLDialect;
-import org.hibernate.sql.Template;
-import org.hibernate.util.StringHelper;
-import org.hibernate.annotations.AccessType;
 import org.hibernate.cfg.AnnotatedClassType;
 import org.hibernate.cfg.AnnotationBinder;
 import org.hibernate.cfg.BinderHelper;
@@ -29,6 +24,7 @@
 import org.hibernate.cfg.PropertyHolderBuilder;
 import org.hibernate.cfg.PropertyPreloadedData;
 import org.hibernate.cfg.SecondPass;
+import org.hibernate.dialect.HSQLDialect;
 import org.hibernate.mapping.Collection;
 import org.hibernate.mapping.Column;
 import org.hibernate.mapping.Component;
@@ -40,12 +36,12 @@
 import org.hibernate.mapping.PersistentClass;
 import org.hibernate.mapping.Property;
 import org.hibernate.mapping.SimpleValue;
-import org.hibernate.mapping.Table;
 import org.hibernate.mapping.ToOne;
 import org.hibernate.mapping.Value;
-import org.hibernate.reflection.XAnnotatedElement;
 import org.hibernate.reflection.XClass;
 import org.hibernate.reflection.XProperty;
+import org.hibernate.sql.Template;
+import org.hibernate.util.StringHelper;
 
 /**
  * Implementation to bind a Map
@@ -53,7 +49,14 @@
  * @author Emmanuel Bernard
  */
 public class MapBinder extends CollectionBinder {
+	public MapBinder(boolean sorted) {
+		super(sorted);
+	}
 
+	public MapBinder() {
+		super();
+	}
+
 	protected Collection createCollection(PersistentClass persistentClass) {
 		return new org.hibernate.mapping.Map( persistentClass );
 	}
@@ -146,9 +149,9 @@
 
 					holder = PropertyHolderBuilder.buildPropertyHolder(
 							mapValue,
-							mapValue.getRole() + "key",
+							StringHelper.qualify( mapValue.getRole(), "mapkey" ),
 							elementClass,
-							property, mappings
+							property, propertyHolder, mappings
 					);
 					//force in case of attribute override
 					boolean attributeOverride = property.isAnnotationPresent( AttributeOverride.class )
@@ -160,10 +163,8 @@
 
 				if ( AnnotatedClassType.EMBEDDABLE.equals( classType ) ) {
 					EntityBinder entityBinder = new EntityBinder();
-					Embeddable embeddable = (Embeddable) elementClass.getAnnotation( Embeddable.class );
 					PersistentClass owner = mapValue.getOwner();
 					boolean isPropertyAnnotated;
-					AccessType access = ( (XAnnotatedElement) elementClass ).getAnnotation( AccessType.class );
 					//FIXME support @Access for collection of elements
 					//String accessType = access != null ? access.value() : null;
 					if ( owner.getIdentifierProperty() != null ) {
@@ -187,7 +188,7 @@
 					Component component = AnnotationBinder.fillComponent(
 							holder, inferredData, isPropertyAnnotated, isPropertyAnnotated ? "property" : "field", true,
 							entityBinder, false, false,
-							mappings
+							true, mappings
 					);
 					mapValue.setIndex( component );
 				}
@@ -195,7 +196,6 @@
 					SimpleValueBinder elementBinder = new SimpleValueBinder();
 					elementBinder.setMappings( mappings );
 					elementBinder.setReturnedClassName( mapKeyType );
-					//FIXME get the columns from an annotation
 
 					Ejb3Column[] elementColumns = mapKeyColumns;
 					if ( elementColumns == null || elementColumns.length == 0 ) {
@@ -222,7 +222,13 @@
 			}
 			//FIXME pass the Index Entity JoinColumns
 			if ( isIndexOfEntities ) {
-				bindManytoManyInverseFk( collectionEntity, mapKeyManyToManyColumns, element, true, mappings );
+				bindManytoManyInverseFk(
+						collectionEntity,
+						mapKeyManyToManyColumns,
+						element,
+						false, //a map key column has no unique constraint
+						mappings
+				);
 			}
 		}
 	}
@@ -240,23 +246,18 @@
 			else if ( element instanceof DependantValue ) {
 				//TODO this never happen I think
 				if ( propertyName != null ) {
-					Collection coll = (Collection) associatedClass.getProperty( propertyName )
-							.getValue();
 					referencedPropertyName = collection.getReferencedPropertyName();
 				}
 				else {
 					throw new AnnotationException( "SecondaryTable JoinColumn cannot reference a non primary key" );
 				}
 			}
-			Table table;
 			Iterator referencedEntityColumns;
 			if (referencedPropertyName == null) {
-				table = associatedClass.getTable();
 				referencedEntityColumns = associatedClass.getIdentifier().getColumnIterator();
 			}
 			else {
-				Property referencedProperty = associatedClass.getProperty( referencedPropertyName );
-				table = referencedProperty.getValue().getTable();
+				Property referencedProperty = associatedClass.getRecursiveProperty( referencedPropertyName );
 				referencedEntityColumns = referencedProperty.getColumnIterator();
 			}
 			String alias = "$alias$";
@@ -268,9 +269,9 @@
 				Column colColumn = (Column) collectionTableColumns.next();
 				Column refColumn = (Column) referencedEntityColumns.next();
 				fromAndWhereSb.append(alias).append('.').append( refColumn.getQuotedName() )
-						.append('=').append( colColumn.getQuotedName() ).append(',');
+						.append('=').append( colColumn.getQuotedName() ).append(" and ");
 			}
-			fromAndWhere = fromAndWhereSb.substring(0, fromAndWhereSb.length() - 1 );
+			fromAndWhere = fromAndWhereSb.substring(0, fromAndWhereSb.length() - 5 );
 		}
 
 		if ( value instanceof Component ) {
@@ -334,7 +335,7 @@
 				}
 				if (fromAndWhere != null) {
 					formulaString = Template.renderWhereStringTemplate( formulaString, "$alias$", new HSQLDialect() );
-					formulaString = "select " +  formulaString + fromAndWhere;
+					formulaString = "(select " +  formulaString + fromAndWhere + ")";
 					formulaString = StringHelper.replace(
 							formulaString,
 							"$alias$",

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/PropertyBinder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/PropertyBinder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -149,8 +149,6 @@
 					throw new AnnotationException("Cannot have @Generated(ALWAYS) property and updatable columns: "
 							+ StringHelper.qualify( holder.getPath(), name ) );
 				}
-				prop.setInsertable( false );
-				prop.setUpdateable( false );
 				prop.setGeneration( PropertyGeneration.parse( generated.toString().toLowerCase() ) );
 			}
 		}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/QueryBinder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/QueryBinder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/QueryBinder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -19,7 +19,7 @@
 import org.hibernate.LockMode;
 import org.hibernate.annotations.CacheModeType;
 import org.hibernate.annotations.FlushModeType;
-import org.hibernate.cfg.AnnotationBinder;
+import org.hibernate.cfg.BinderHelper;
 import org.hibernate.cfg.ExtendedMappings;
 import org.hibernate.cfg.NotYetImplementedException;
 import org.hibernate.engine.NamedQueryDefinition;
@@ -37,7 +37,7 @@
 
 	public static void bindQuery(NamedQuery queryAnn, ExtendedMappings mappings, boolean isDefault) {
 		if ( queryAnn == null ) return;
-		if ( AnnotationBinder.isDefault( queryAnn.name() ) ) {
+		if ( BinderHelper.isDefault( queryAnn.name() ) ) {
 			throw new AnnotationException( "A named query must have a name when used in class or package level" );
 		}
 		//EJBQL Query
@@ -68,14 +68,14 @@
 	public static void bindNativeQuery(NamedNativeQuery queryAnn, ExtendedMappings mappings, boolean isDefault) {
 		if ( queryAnn == null ) return;
 		//ResultSetMappingDefinition mappingDefinition = mappings.getResultSetMapping( queryAnn.resultSetMapping() );
-		if ( AnnotationBinder.isDefault( queryAnn.name() ) ) {
+		if ( BinderHelper.isDefault( queryAnn.name() ) ) {
 			throw new AnnotationException( "A named query must have a name when used in class or package level" );
 		}
 		NamedSQLQueryDefinition query;
 		String resultSetMapping = queryAnn.resultSetMapping();
 		QueryHint[] hints = queryAnn.hints();
 		String queryName = queryAnn.query();
-		if ( ! AnnotationBinder.isDefault( resultSetMapping ) ) {
+		if ( ! BinderHelper.isDefault( resultSetMapping ) ) {
 			//sql result set usage
 			query = new NamedSQLQueryDefinition(
 					queryName,
@@ -131,25 +131,25 @@
 	public static void bindNativeQuery(org.hibernate.annotations.NamedNativeQuery queryAnn, ExtendedMappings mappings) {
 		if ( queryAnn == null ) return;
 		//ResultSetMappingDefinition mappingDefinition = mappings.getResultSetMapping( queryAnn.resultSetMapping() );
-		if ( AnnotationBinder.isDefault( queryAnn.name() ) ) {
+		if ( BinderHelper.isDefault( queryAnn.name() ) ) {
 			throw new AnnotationException( "A named query must have a name when used in class or package level" );
 		}
 		NamedSQLQueryDefinition query;
 		String resultSetMapping = queryAnn.resultSetMapping();
-		if ( ! AnnotationBinder.isDefault( resultSetMapping ) ) {
+		if ( ! BinderHelper.isDefault( resultSetMapping ) ) {
 			//sql result set usage
 			query = new NamedSQLQueryDefinition(
 					queryAnn.query(),
 					resultSetMapping,
 					null,
 					queryAnn.cacheable(),
-					AnnotationBinder.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
+					BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
 					queryAnn.timeout() < 0 ? null : queryAnn.timeout(),
 					queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(),
 					getFlushMode( queryAnn.flushMode() ),
 					getCacheMode( queryAnn.cacheMode() ),
 					queryAnn.readOnly(),
-					AnnotationBinder.isDefault( queryAnn.comment() ) ? null : queryAnn.comment(),
+					BinderHelper.isDefault( queryAnn.comment() ) ? null : queryAnn.comment(),
 					null,
 					queryAnn.callable()
 			);
@@ -164,13 +164,13 @@
 					new NativeSQLQueryReturn[]{entityQueryReturn},
 					null,
 					queryAnn.cacheable(),
-					AnnotationBinder.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
+					BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
 					queryAnn.timeout() < 0 ? null : queryAnn.timeout(),
 					queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(),
 					getFlushMode( queryAnn.flushMode() ),
 					getCacheMode( queryAnn.cacheMode() ),
 					queryAnn.readOnly(),
-					AnnotationBinder.isDefault( queryAnn.comment() ) ? null : queryAnn.comment(),
+					BinderHelper.isDefault( queryAnn.comment() ) ? null : queryAnn.comment(),
 					null,
 					queryAnn.callable()
 			);
@@ -209,7 +209,7 @@
 
 	public static void bindQuery(org.hibernate.annotations.NamedQuery queryAnn, ExtendedMappings mappings) {
 		if ( queryAnn == null ) return;
-		if ( AnnotationBinder.isDefault( queryAnn.name() ) ) {
+		if ( BinderHelper.isDefault( queryAnn.name() ) ) {
 			throw new AnnotationException( "A named query must have a name when used in class or package level" );
 		}
 
@@ -219,13 +219,13 @@
 		NamedQueryDefinition query = new NamedQueryDefinition(
 				queryAnn.query(),
 				queryAnn.cacheable(),
-				AnnotationBinder.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
+				BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
 				queryAnn.timeout() < 0 ? null : queryAnn.timeout(),
 				queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(),
 				flushMode,
 				getCacheMode( queryAnn.cacheMode() ),
 				queryAnn.readOnly(),
-				AnnotationBinder.isDefault( queryAnn.comment() ) ? null : queryAnn.comment(),
+				BinderHelper.isDefault( queryAnn.comment() ) ? null : queryAnn.comment(),
 				null
 		);
 
@@ -246,8 +246,11 @@
 				flushMode = FlushMode.COMMIT;
 				break;
 			case NEVER:
-				flushMode = FlushMode.NEVER;
+				flushMode = FlushMode.MANUAL;
 				break;
+			case MANUAL:
+				flushMode = FlushMode.MANUAL;
+				break;
 			default:
 				throw new AssertionFailure( "Unknown flushModeType: " + flushModeType );
 		}
@@ -282,11 +285,13 @@
 	public static void bindSqlResultsetMappings(SqlResultSetMappings ann, ExtendedMappings mappings, boolean isDefault) {
 		if ( ann == null ) return;
 		for ( SqlResultSetMapping rs : ann.value() ) {
+			//no need to handle inSecondPass
 			mappings.addSecondPass( new ResultsetMappingSecondPass( rs, mappings, true ) );
 		}
 	}
 
 	public static void bindSqlResultsetMapping(SqlResultSetMapping ann, ExtendedMappings mappings, boolean isDefault) {
+		//no need to handle inSecondPass
 		mappings.addSecondPass( new ResultsetMappingSecondPass( ann, mappings, isDefault ) );
 	}
 
@@ -329,8 +334,11 @@
 					return FlushMode.COMMIT;
 				}
 				else if ( hint.value().equalsIgnoreCase( FlushMode.NEVER.toString() ) ) {
-					return FlushMode.NEVER;
+					return FlushMode.MANUAL;
 				}
+				else if ( hint.value().equalsIgnoreCase( FlushMode.MANUAL.toString() ) ) {
+					return FlushMode.MANUAL;
+				}
 				else {
 					throw new AnnotationException( "Unknown FlushMode in hint: " + query + ":" + hint.name() );
 				}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -17,7 +17,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.LockMode;
 import org.hibernate.MappingException;
-import org.hibernate.cfg.AnnotationBinder;
+import org.hibernate.cfg.BinderHelper;
 import org.hibernate.cfg.ExtendedMappings;
 import org.hibernate.cfg.QuerySecondPass;
 import org.hibernate.engine.ResultSetMappingDefinition;
@@ -46,7 +46,7 @@
 		this.isDefault = isDefault;
 	}
 
-	public void doSecondPass(Map persistentClasses, Map inheritedMetas) throws MappingException {
+	public void doSecondPass(Map persistentClasses) throws MappingException {
 		//TODO add parameters checkings
 		if ( ann == null ) return;
 		ResultSetMappingDefinition definition = new ResultSetMappingDefinition( ann.name() );
@@ -136,7 +136,7 @@
 				}
 			}
 
-			if ( ! AnnotationBinder.isDefault( entity.discriminatorColumn() ) ) {
+			if ( ! BinderHelper.isDefault( entity.discriminatorColumn() ) ) {
 				propertyresults.put( "class", new String[]{entity.discriminatorColumn()} );
 			}
 

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -16,7 +16,7 @@
 import org.hibernate.AssertionFailure;
 import org.hibernate.annotations.Parameter;
 import org.hibernate.annotations.Type;
-import org.hibernate.cfg.AnnotationBinder;
+import org.hibernate.cfg.BinderHelper;
 import org.hibernate.cfg.Ejb3Column;
 import org.hibernate.cfg.ExtendedMappings;
 import org.hibernate.cfg.NotYetImplementedException;
@@ -45,6 +45,7 @@
 	private String explicitType = "";
 	private Properties typeParameters = new Properties();
 	private ExtendedMappings mappings;
+	private Table table;
 
 	public void setPropertyName(String propertyName) {
 		this.propertyName = propertyName;
@@ -54,6 +55,10 @@
 		this.returnedClassName = returnedClassName;
 	}
 
+	public void setTable(Table table) {
+		this.table = table;
+	}
+
 	public void setColumns(Ejb3Column[] columns) {
 		this.columns = columns;
 	}
@@ -74,7 +79,7 @@
 		}
 		Properties typeParameters = this.typeParameters;
 		typeParameters.clear();
-		String type = AnnotationBinder.ANNOTATION_STRING_DEFAULT;
+		String type = BinderHelper.ANNOTATION_STRING_DEFAULT;
 		if ( property.isAnnotationPresent( Temporal.class ) ) {
 			Temporal ann = property.getAnnotation( Temporal.class );
 			boolean isDate;
@@ -152,7 +157,7 @@
 		if ( columns == null ) {
 			throw new AssertionFailure( "SimpleValueBinder.setColumns should be set before SimpleValueBinder.setType" );
 		}
-		if ( AnnotationBinder.ANNOTATION_STRING_DEFAULT.equals( type ) ) {
+		if ( BinderHelper.ANNOTATION_STRING_DEFAULT.equals( type ) ) {
 			if ( returnedClassOrElement.isEnum() ) {
 				type = EnumType.class.getName();
 				typeParameters = new Properties();
@@ -213,13 +218,15 @@
 	public SimpleValue make() {
 		validate();
 		log.debug( "building SimpleValue for " + propertyName );
-		Table table = columns[0].getTable();
+		if (table == null) {
+			table = columns[0].getTable();
+		}
 		SimpleValue simpleValue = new SimpleValue( table );
 		return fillSimpleValue( simpleValue );
 	}
 
-	private SimpleValue fillSimpleValue(SimpleValue simpleValue) {
-		String type = AnnotationBinder.isDefault( explicitType ) ? returnedClassName : explicitType;
+	public SimpleValue fillSimpleValue(SimpleValue simpleValue) {
+		String type = BinderHelper.isDefault( explicitType ) ? returnedClassName : explicitType;
 		org.hibernate.mapping.TypeDef typeDef = mappings.getTypeDef( type );
 		if ( typeDef != null ) {
 			type = typeDef.getTypeClass();

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/TableBinder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/TableBinder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/TableBinder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -11,7 +11,7 @@
 import org.hibernate.AnnotationException;
 import org.hibernate.AssertionFailure;
 import org.hibernate.annotations.Index;
-import org.hibernate.cfg.AnnotationBinder;
+import org.hibernate.cfg.BinderHelper;
 import org.hibernate.cfg.Ejb3JoinColumn;
 import org.hibernate.cfg.ExtendedMappings;
 import org.hibernate.cfg.IndexSecondPass;
@@ -107,8 +107,8 @@
 			String schema, String catalog, String realTableName, String logicalName, boolean isAbstract,
 			List uniqueConstraints, String constraints, Table denormalizedSuperTable, ExtendedMappings mappings
 	) {
-		schema = AnnotationBinder.isDefault( schema ) ? mappings.getSchemaName() : schema;
-		catalog = AnnotationBinder.isDefault( catalog ) ? mappings.getCatalogName() : catalog;
+		schema = BinderHelper.isDefault( schema ) ? mappings.getSchemaName() : schema;
+		catalog = BinderHelper.isDefault( catalog ) ? mappings.getCatalogName() : catalog;
 		Table table;
 		if ( denormalizedSuperTable != null ) {
 			table = mappings.addDenormalizedTable(
@@ -166,7 +166,7 @@
 				);
 			}
 
-			final Property property = associatedClass.getProperty( columns[0].getMappedBy() );
+			final Property property = associatedClass.getRecursiveProperty( columns[0].getMappedBy() );
 			Iterator mappedByColumns;
 			if ( property.getValue() instanceof Collection ) {
 				Collection collection = ( (Collection) property.getValue() );
@@ -217,7 +217,7 @@
 				else if ( value instanceof DependantValue ) {
 					String propertyName = columns[0].getPropertyName();
 					if ( propertyName != null ) {
-						Collection collection = (Collection) referencedEntity.getProperty( propertyName )
+						Collection collection = (Collection) referencedEntity.getRecursiveProperty( propertyName )
 								.getValue();
 						referencedPropertyName = collection.getReferencedPropertyName();
 					}
@@ -237,7 +237,7 @@
 							"No property ref found while expected"
 					);
 				}
-				Property synthProp = referencedEntity.getProperty( referencedPropertyName );
+				Property synthProp = referencedEntity.getRecursiveProperty( referencedPropertyName );
 				if ( synthProp == null ) {
 					throw new AssertionFailure(
 							"Cannot find synthProp: " + referencedEntity.getEntityName() + "." + referencedPropertyName
@@ -254,6 +254,7 @@
 					if ( columns.length != referencedEntity.getIdentifier().getColumnSpan() ) {
 						throw new AnnotationException(
 								"A Foreign key refering " + referencedEntity.getEntityName()
+										+ " from " + associatedClass.getEntityName()
 										+ " has the wrong number of column. should be " + referencedEntity.getIdentifier()
 										.getColumnSpan()
 						);
@@ -293,7 +294,7 @@
 								break;
 							}
 						}
-						if ( match == false ) {
+						if ( !match ) {
 							throw new AnnotationException(
 									"Column name " + col.getName() + " of "
 											+ referencedEntity.getEntityName() + " not found in JoinColumns.referencedColumnName"
@@ -336,6 +337,7 @@
 
 	public static void addIndexes(Table hibTable, Index[] indexes, ExtendedMappings mappings) {
 		for ( Index index : indexes ) {
+			//no need to handle inSecondPass here since it is only called from EntityBinder
 			mappings.addSecondPass(
 					new IndexSecondPass( hibTable, index.name(), index.columnNames(), mappings )
 			);

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/Version.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/Version.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/Version.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -8,7 +8,7 @@
  * @author Emmanuel Bernard
  */
 public class Version {
-	public static String VERSION = "3.2.0.CR1";
+	public static final String VERSION = "3.2.0.CR3";
 	private static Log log = LogFactory.getLog( Version.class );
 
 	static {

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -18,6 +18,7 @@
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
 import org.hibernate.HibernateException;
+import org.hibernate.util.ReflectHelper;
 import org.hibernate.cfg.Configuration;
 import org.hibernate.event.Initializable;
 import org.hibernate.event.PostDeleteEvent;
@@ -53,7 +54,7 @@
 
 
 	private Map<Class, DocumentBuilder<Object>> documentBuilders = new HashMap<Class, DocumentBuilder<Object>>();
-	//** keep track of the index modifiers per file since 1 index modifier can be present at a time */
+	//keep track of the index modifiers per DirectoryProvider since multiple entity can use the same directory provider
 	private Map<DirectoryProvider, Lock> indexLock = new HashMap<DirectoryProvider, Lock>();
 	private boolean initialized;
 
@@ -66,7 +67,7 @@
 		String analyzerClassName = cfg.getProperty( Environment.ANALYZER_CLASS );
 		if ( analyzerClassName != null ) {
 			try {
-				analyzerClass = Class.forName( analyzerClassName );
+				analyzerClass = ReflectHelper.classForName( analyzerClassName );
 			}
 			catch (Exception e) {
 				throw new HibernateException(

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -3,7 +3,6 @@
 
 import java.util.Properties;
 
-import org.hibernate.cfg.Configuration;
 import org.apache.lucene.store.Directory;
 
 
@@ -18,9 +17,12 @@
  * @author Sylvain Vieujot
  */
 public interface DirectoryProvider<TDirectory extends Directory> {
-	/** get the information toi initialize the directory and build its hashCode */
-	void initialize(Class<?> entity, Configuration cfg, Properties properties);
+	/** get the information to initialize the directory and build its hashCode */
+	void initialize(String directoryProviderName, Properties properties);
 
+	/**
+	 * Returns an initialized Lucene Directory. This method call <b>must</b> be threadsafe
+	 */
 	TDirectory getDirectory();
 }
 

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -7,6 +7,7 @@
 import java.util.Properties;
 
 import org.hibernate.HibernateException;
+import org.hibernate.mapping.PersistentClass;
 import org.hibernate.cfg.Configuration;
 import org.hibernate.lucene.Indexed;
 import org.hibernate.util.ReflectHelper;
@@ -39,8 +40,9 @@
 
 	public DirectoryProvider<?> createDirectoryProvider(Class<?> entity, Configuration cfg) {
 		//get properties
-		Properties indexProps = getDirectoryProperties( cfg, entity );
-
+		String directoryProviderName = getDirectoryProviderName( entity, cfg );
+		Properties indexProps = getDirectoryProperties( cfg, directoryProviderName );
+		
 		//set up the directory
 		String className = indexProps.getProperty( "directory_provider" );
 		if ( StringHelper.isEmpty( className ) ) {
@@ -56,7 +58,7 @@
 		catch (Exception e) {
 			throw new HibernateException( "Unable to instanciate directory provider: " + className, e );
 		}
-		provider.initialize( entity, cfg, indexProps );
+		provider.initialize( directoryProviderName, indexProps );
 		int index = providers.indexOf( provider );
 		if ( index != -1 ) {
 			//share the same Directory provider for the same underlying store
@@ -68,13 +70,13 @@
 		}
 	}
 
-	private static Properties getDirectoryProperties(Configuration cfg, Class<?> entity) {
+	private static Properties getDirectoryProperties(Configuration cfg, String directoryProviderName) {
 		Properties props = cfg.getProperties();
-		String indexName = LUCENE_PREFIX + getTypeName( entity );
+		String indexName = LUCENE_PREFIX + directoryProviderName;
 		Properties indexProps = new Properties();
 		Properties indexSpecificProps = new Properties();
-		for ( Map.Entry<String, ?> entry : ( (Map<String, ?>) props ).entrySet() ) {
-			String key = entry.getKey();
+		for ( Map.Entry entry : props.entrySet() ) {
+			String key = (String) entry.getKey();
 			if ( key.startsWith( LUCENE_DEFAULT ) ) {
 				indexProps.setProperty( key.substring( LUCENE_DEFAULT.length() ), (String) entry.getValue() );
 			}
@@ -86,8 +88,42 @@
 		return indexProps;
 	}
 
-	public static String getTypeName(Class<?> clazz) {
+	@Deprecated
+	public static String getTypeNameOld(Class<?> clazz) {
 		String name = clazz.getAnnotation(Indexed.class).index();
 		return "".equals( name ) ? clazz.getName() : name;
 	}
+
+	public static String getDirectoryProviderName(Class<?> clazz, Configuration cfg) {
+		//get the most specialized (ie subclass > superclass) non default index name
+		//if none extract the name from the most generic (superclass > subclass) @Indexed class in the hierarchy
+		//FIXME I'm inclined to get rid of the default value
+		PersistentClass pc = cfg.getClassMapping( clazz.getName() );
+		Class rootIndex = null;
+		do {
+			Class<?> currentClazz = pc.getMappedClass();
+			Indexed indexAnn = currentClazz.getAnnotation( Indexed.class );
+			if (indexAnn != null) {
+				if ( indexAnn.index().length() != 0 ) {
+					return indexAnn.index();
+				}
+				else {
+					rootIndex = currentClazz;
+				}
+			}
+            pc = pc.getSuperclass();
+		} while (pc != null);
+		//there is nobody outthere with a non default @Indexed.index
+		if (rootIndex != null) {
+			return rootIndex.getName();
+		}
+		else {
+			if (clazz == null) {
+				throw new HibernateException("Trying to extract the index name a null entity");
+			}
+			else {
+				throw new HibernateException("Trying to extract the index name from a non @Indexed class: " + clazz.getName() );
+			}
+		}
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -12,7 +12,6 @@
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.store.FSDirectory;
 import org.hibernate.HibernateException;
-import org.hibernate.cfg.Configuration;
 
 /**
  * Use a Lucene FSDirectory
@@ -27,7 +26,7 @@
 	private static Log log = LogFactory.getLog( FSDirectoryProvider.class );
 	private String indexName;
 
-	public void initialize(Class entity, @SuppressWarnings("unused") Configuration cfg, Properties properties) {
+	public void initialize(String directoryProviderName, Properties properties) {
 		String indexBase = properties.getProperty( "indexBase", "." );
 		File indexDir = new File( indexBase );
 
@@ -40,8 +39,7 @@
 		}
 		log.info( "Setting index dir to " + indexDir );
 
-		String fileName = DirectoryProviderFactory.getTypeName( entity );
-		File file = new File( indexDir, fileName );
+		File file = new File( indexDir, directoryProviderName );
 
 		try {
 			boolean create = !file.exists();
@@ -53,7 +51,7 @@
 			}
 		}
 		catch (IOException e) {
-			throw new HibernateException( "Unable to initialize index: " + fileName, e );
+			throw new HibernateException( "Unable to initialize index: " + directoryProviderName, e );
 		}
 
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -8,7 +8,6 @@
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.store.RAMDirectory;
 import org.hibernate.HibernateException;
-import org.hibernate.cfg.Configuration;
 
 /**
  * Use a Lucene RAMDirectory
@@ -21,8 +20,8 @@
 	private RAMDirectory directory;
 	private String indexName;
 
-	public void initialize(Class entity, Configuration cfg, Properties properties) {
-		indexName = DirectoryProviderFactory.getTypeName( entity );
+	public void initialize(String directoryProviderName, Properties properties) {
+		indexName = directoryProviderName;
 		directory = new RAMDirectory();
 		try {
 			IndexWriter iw = new IndexWriter(directory, new StandardAnalyzer(), true );

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/EJB3OverridenAnnotationReader.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/EJB3OverridenAnnotationReader.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/EJB3OverridenAnnotationReader.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -175,7 +175,6 @@
 	private String className;
 	private String propertyName;
 	private PropertyType propertyType;
-	private boolean isFieldAccess;
 	private transient Annotation[] annotations;
 	private static final String WORD_SEPARATOR = "-";
 	private transient List<Element> elementsForProperty;
@@ -353,6 +352,11 @@
 					getAssociation( OneToOne.class, annotationList, defaults );
 					getAssociation( OneToMany.class, annotationList, defaults );
 					getAssociation( ManyToMany.class, annotationList, defaults );
+					Annotation current = getSequenceGenerator( tree, defaults );
+					if ( current != null ) annotationList.add( current );
+					current = getTableGenerator( tree, defaults );
+					if ( current != null ) annotationList.add( current );
+
 				}
 				processEventAnnotations(annotationList, defaults);
 				this.annotations = annotationList.toArray( new Annotation[ annotationList.size() ] );
@@ -453,11 +457,19 @@
 		}
 	}
 
-	private JoinTable overridesDefaultsInJoinTable(XMLContext.Default defaults) {
+	private JoinTable overridesDefaultsInJoinTable(Annotation annotation, XMLContext.Default defaults) {
 		//no element but might have some default or some annotation
+		boolean defaultToJoinTable = ! ( super.isAnnotationPresent( JoinColumn.class )
+				|| super.isAnnotationPresent( JoinColumns.class ) );
+		defaultToJoinTable = defaultToJoinTable &&
+				( ( annotation.annotationType() == ManyToMany.class && StringHelper.isEmpty( ( (ManyToMany) annotation).mappedBy() ) )
+				  || ( annotation.annotationType() == OneToMany.class && StringHelper.isEmpty( ( (OneToMany) annotation).mappedBy() ) )
+				  || ( annotation.annotationType() == CollectionOfElements.class )
+				);
 		final Class<JoinTable> annotationType = JoinTable.class;
-		if ( StringHelper.isNotEmpty( defaults.getCatalog() )
-				|| StringHelper.isNotEmpty( defaults.getSchema() ) ) {
+		if ( defaultToJoinTable
+				&& ( StringHelper.isNotEmpty( defaults.getCatalog() )
+					|| StringHelper.isNotEmpty( defaults.getSchema() ) ) ) {
 			AnnotationDescriptor ad = new AnnotationDescriptor( annotationType );
 			if ( defaults.canUseJavaAnnotations() ) {
 				JoinTable table = super.getAnnotation( annotationType );
@@ -555,7 +567,7 @@
 			Annotation annotation = super.getAnnotation( annotationType );
 			if ( annotation != null ) {
 				annotationList.add( annotation );
-				annotation = overridesDefaultsInJoinTable( defaults );
+				annotation = overridesDefaultsInJoinTable( annotation, defaults );
 				if ( annotation != null ) annotationList.add( annotation );
 				annotation = super.getAnnotation( JoinColumn.class );
 				if ( annotation != null ) annotationList.add( annotation );
@@ -589,7 +601,7 @@
 				if ( annotation != null ) annotationList.add( annotation );
 			}
 			else if ( super.isAnnotationPresent( CollectionOfElements.class ) ) {
-				annotation = overridesDefaultsInJoinTable( defaults );
+				annotation = overridesDefaultsInJoinTable( super.getAnnotation( CollectionOfElements.class ), defaults );
 				if ( annotation != null ) annotationList.add( annotation );
 				annotation = super.getAnnotation( JoinColumn.class );
 				if ( annotation != null ) annotationList.add( annotation );
@@ -725,7 +737,7 @@
 			//we have nothing, so Java annotations might occurs
 			Annotation annotation = super.getAnnotation( Version.class );
 			if ( annotation != null ) {
-				if ( annotation != null ) annotationList.add( annotation );
+				annotationList.add( annotation );
 				annotation = super.getAnnotation( Column.class );
 				if ( annotation != null ) annotationList.add( annotation );
 				annotation = super.getAnnotation( Columns.class );
@@ -815,9 +827,6 @@
 	private void getEmbeddedId(List<Annotation> annotationList, XMLContext.Default defaults) {
 		for ( Element element : elementsForProperty ) {
 			if ( "embedded-id".equals( element.getName() ) ) {
-				//boolean properAccessOnMetadataComplete = computeProperAccessOnMetadataComplete( defaults );
-				//boolean properOverridingOnMetadataNonComplete = computeProperOverridingOnMetadataNonComplete( defaults );
-				//if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) {
 				if ( isProcessingId( defaults ) ) {
 					Annotation annotation = getAttributeOverrides( element, defaults );
 					if ( annotation != null ) annotationList.add( annotation );
@@ -895,8 +904,6 @@
 	private void getId(List<Annotation> annotationList, XMLContext.Default defaults) {
 		for ( Element element : elementsForProperty ) {
 			if ( "id".equals( element.getName() ) ) {
-				//boolean properAccessOnMetadataComplete = computeProperAccessOnMetadataComplete( defaults );
-				//boolean properOverridingOnMetadataNonComplete = computeProperOverridingOnMetadataNonComplete( defaults );
 				boolean processId = isProcessingId( defaults );
 				if ( processId ) {
 					Annotation annotation = buildColumns( element );
@@ -958,8 +965,8 @@
 	private boolean isProcessingId(XMLContext.Default defaults) {
 		boolean isExplicit = defaults.getAccess() != null;
 		boolean correctAccess =
-				( PropertyType.PROPERTY.equals( propertyType ) && "property".equalsIgnoreCase( defaults.getAccess() ) )
-				|| ( PropertyType.FIELD.equals( propertyType ) && "field".equalsIgnoreCase( defaults.getAccess() ) );
+				( PropertyType.PROPERTY.equals( propertyType ) && "property".equals( defaults.getAccess() ) )
+				|| ( PropertyType.FIELD.equals( propertyType ) && "field".equals( defaults.getAccess() ) );
 		boolean hasId = defaults.canUseJavaAnnotations()
 				&& ( super.isAnnotationPresent( Id.class ) || super.isAnnotationPresent( EmbeddedId.class ) );
 		//if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) {
@@ -972,23 +979,11 @@
 		return correctAccess || ( ! isExplicit && hasId ) || ( ! isExplicit && propertyIsDefault );
 	}
 
-	private boolean computeProperOverridingOnMetadataNonComplete(XMLContext.Default defaults) {
-		return defaults.canUseJavaAnnotations()
-				&& super.isAnnotationPresent( Id.class );
-	}
-
-	private boolean computeProperAccessOnMetadataComplete(XMLContext.Default defaults) {
-		return ( ! defaults.canUseJavaAnnotations() )
-				&& ( ( ! "field".equalsIgnoreCase( defaults.getAccess() ) && ! PropertyType.FIELD
-				.equals( propertyType ) )
-				|| ( "field".equalsIgnoreCase( defaults.getAccess() ) && PropertyType.FIELD.equals( propertyType ) ) );
-	}
-
 	private Columns buildColumns(Element element) {
 		List<Element> subelements = element.elements( "column" );
 		List<Column> columns = new ArrayList<Column>( subelements.size() );
 		for ( Element subelement : subelements ) {
-			columns.add( getColumn( subelement, false ) );
+			columns.add( getColumn( subelement, false, element ) );
 		}
 		if ( columns.size() > 0 ) {
 			AnnotationDescriptor columnsDescr = new AnnotationDescriptor( Columns.class );
@@ -1151,14 +1146,14 @@
 				AnnotationDescriptor override = new AnnotationDescriptor( AttributeOverride.class );
 				copyStringAttribute( override, current, "name", true );
 				Element column = current != null ? current.element( "column" ) : null;
-				override.setValue( "column", getColumn( column, true ) );
+				override.setValue( "column", getColumn( column, true, current ) );
 				overrides.add( (AttributeOverride) AnnotationFactory.create( override ) );
 			}
 		}
 		return overrides;
 	}
 
-	private Column getColumn(Element element, boolean isMandatory) {
+	private Column getColumn(Element element, boolean isMandatory, Element current) {
 		//Element subelement = element != null ? element.element( "column" ) : null;
 		if ( element != null ) {
 			AnnotationDescriptor column = new AnnotationDescriptor( Column.class );
@@ -1176,7 +1171,7 @@
 		}
 		else {
 			if ( isMandatory ) {
-				throw new AnnotationException( element.getPath() + " is mandatory. " + SCHEMA_VALIDATION );
+				throw new AnnotationException( current.getPath() + ".column is mandatory. " + SCHEMA_VALIDATION );
 			}
 			return null;
 		}
@@ -1198,26 +1193,24 @@
 
 	private AccessType getAccessType(Element tree, XMLContext.Default defaults) {
 		String access = tree == null ? null : tree.attributeValue( "access" );
-		if ( "FIELD".equals( access ) || "PROPERTY".equals( access ) ) access = access.toLowerCase();
+		if ( "FIELD".equals( access ) || "PROPERTY".equals( access ) ) {
+			access = access.toLowerCase();
+		}
 		if ( access != null ) {
 			AnnotationDescriptor ad = new AnnotationDescriptor( AccessType.class );
 			ad.setValue( "value", access );
-			isFieldAccess = "field".equalsIgnoreCase( access );
 			return AnnotationFactory.create( ad );
 		}
 		else if ( defaults.canUseJavaAnnotations() && super.isAnnotationPresent( AccessType.class ) ) {
 			AccessType annotation = super.getAnnotation( AccessType.class );
-			isFieldAccess = "field".equalsIgnoreCase( annotation != null ? annotation.value() : null );
 			return annotation;
 		}
 		else if ( defaults.getAccess() != null ) {
 			AnnotationDescriptor ad = new AnnotationDescriptor( AccessType.class );
 			ad.setValue( "value", defaults.getAccess() );
-			isFieldAccess = "field".equalsIgnoreCase( defaults.getAccess() );
 			return AnnotationFactory.create( ad );
 		}
 		else {
-			isFieldAccess = false;
 			return null;
 		}
 	}
@@ -1319,7 +1312,21 @@
 				columnResults.add( (ColumnResult) AnnotationFactory.create( columnResultDescriptor ) );
 			}
 			ann.setValue( "columns", columnResults.toArray( new ColumnResult[ columnResults.size() ] ) );
-			copyStringAttribute( ann, subelement, "result-class", false );
+			//FIXME there is never such a result-class, get rid of it?
+			String clazzName = subelement.attributeValue( "result-class" );
+			if ( StringHelper.isNotEmpty( clazzName ) ) {
+				Class clazz = null;
+				try {
+					clazz = ReflectHelper.classForName(
+							XMLContext.buildSafeClassName( clazzName, defaults ),
+							EJB3OverridenAnnotationReader.class
+					);
+				}
+				catch (ClassNotFoundException e) {
+					throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
+				}
+				ann.setValue( "resultClass", clazz );
+			}
 			copyStringAttribute( ann, subelement, "result-set-mapping", false );
 			resultsets.add( (SqlResultSetMapping) AnnotationFactory.create( ann ) );
 		}
@@ -1341,7 +1348,7 @@
 	}
 
 	private NamedQueries getNamedQueries(Element tree, XMLContext.Default defaults) {
-		List<NamedQuery> queries = (List<NamedQuery>) buildNamedQueries( tree, false );
+		List<NamedQuery> queries = (List<NamedQuery>) buildNamedQueries( tree, false, defaults );
 		if ( defaults.canUseJavaAnnotations() ) {
 			NamedQuery annotation = super.getAnnotation( NamedQuery.class );
 			addNamedQueryIfNeeded( annotation, queries );
@@ -1377,7 +1384,7 @@
 	}
 
 	private NamedNativeQueries getNamedNativeQueries(Element tree, XMLContext.Default defaults) {
-		List<NamedNativeQuery> queries = (List<NamedNativeQuery>) buildNamedQueries( tree, true );
+		List<NamedNativeQuery> queries = (List<NamedNativeQuery>) buildNamedQueries( tree, true, defaults );
 		if ( defaults.canUseJavaAnnotations() ) {
 			NamedNativeQuery annotation = super.getAnnotation( NamedNativeQuery.class );
 			addNamedNativeQueryIfNeeded( annotation, queries );
@@ -1412,7 +1419,7 @@
 		}
 	}
 
-	public static List buildNamedQueries(Element element, boolean isNative) {
+	public static List buildNamedQueries(Element element, boolean isNative, XMLContext.Default defaults) {
 		if ( element == null ) return new ArrayList();
 		List namedQueryElementList = isNative ?
 				element.elements( "named-native-query" ) :
@@ -1442,7 +1449,20 @@
 				queryHints.add( (QueryHint) AnnotationFactory.create( hintDescriptor ) );
 			}
 			ann.setValue( "hints", queryHints.toArray( new QueryHint[ queryHints.size() ] ) );
-			copyStringAttribute( ann, subelement, "result-class", false );
+			String clazzName = subelement.attributeValue( "result-class" );
+			if ( StringHelper.isNotEmpty( clazzName ) ) {
+				Class clazz = null;
+				try {
+					clazz = ReflectHelper.classForName(
+							XMLContext.buildSafeClassName( clazzName, defaults ),
+							EJB3OverridenAnnotationReader.class
+					);
+				}
+				catch (ClassNotFoundException e) {
+					throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
+				}
+				ann.setValue( "resultClass", clazz );
+			}
 			copyStringAttribute( ann, subelement, "result-set-mapping", false );
 			namedQueries.add( AnnotationFactory.create( ann ) );
 		}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXAnnotatedElement.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXAnnotatedElement.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXAnnotatedElement.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -52,6 +52,7 @@
 	public boolean equals(Object obj) {
 		if ( obj == null || ! ( obj instanceof JavaXAnnotatedElement ) ) return false;
 		JavaXAnnotatedElement other = (JavaXAnnotatedElement) obj;
+		//FIXME yuk this defeat the type environment
 		return toAnnotatedElement().equals( other.toAnnotatedElement() );
 	}
 

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXArrayType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXArrayType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXArrayType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -32,6 +32,7 @@
 	}
 
 	private Type getElementType() {
+		//TODO make it a static class for faster performance?
 		return new TypeSwitch<Type>() {
 			@Override
 			public Type caseClass(Class classType) {

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -11,6 +11,7 @@
 import org.hibernate.reflection.XMethod;
 import org.hibernate.reflection.XProperty;
 import org.hibernate.reflection.java.generics.TypeEnvironment;
+import org.hibernate.reflection.java.generics.CompoundTypeEnvironment;
 
 /**
  * @author Paolo Perrotta
@@ -30,14 +31,20 @@
 	}
 
 	public XClass getSuperclass() {
-		return getFactory().toXClass( toClass().getSuperclass(), getFactory().getTypeEnvironment( toClass() ) );
+		//return getFactory().toXClass( toClass().getSuperclass(), getFactory().getTypeEnvironment( toClass() ) );
+		return getFactory().toXClass( toClass().getSuperclass(),
+				new CompoundTypeEnvironment( getTypeEnvironment(), getFactory().getTypeEnvironment( toClass() )
+				)
+		);
 	}
 
 	public XClass[] getInterfaces() {
 		Class[] classes = toClass().getInterfaces();
 		int length = classes.length;
 		XClass[] xClasses = new XClass[length];
-		TypeEnvironment environment = getFactory().getTypeEnvironment( toClass() );
+		//TypeEnvironment environment = getFactory().getTypeEnvironment( toClass() );
+		TypeEnvironment environment =
+				new CompoundTypeEnvironment( getTypeEnvironment(), getFactory().getTypeEnvironment( toClass() ) );
 		for ( int index = 0; index < length ; index++ ) {
 			xClasses[index] = getFactory().toXClass( classes[index], environment );
 		}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXCollectionType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXCollectionType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXCollectionType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -4,6 +4,7 @@
 import java.lang.reflect.Type;
 import java.util.Collection;
 import java.util.Map;
+import java.util.SortedMap;
 
 import org.hibernate.reflection.XClass;
 import org.hibernate.reflection.java.generics.TypeEnvironment;
@@ -34,7 +35,9 @@
 			public XClass caseParameterizedType(ParameterizedType parameterizedType) {
 				Type[] args = parameterizedType.getActualTypeArguments();
 				Type componentType;
-				if ( getCollectionClass().isAssignableFrom( Map.class ) ) {
+				Class<? extends Collection> collectionClass = getCollectionClass();
+				if ( collectionClass.isAssignableFrom( Map.class )
+						|| collectionClass.isAssignableFrom( SortedMap.class ) ) {
 					componentType = args[1];
 				}
 				else {

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -8,15 +8,13 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import javax.persistence.EntityListeners;
 import javax.persistence.NamedNativeQuery;
 import javax.persistence.NamedQuery;
 import javax.persistence.SequenceGenerator;
 import javax.persistence.SqlResultSetMapping;
 import javax.persistence.TableGenerator;
-import javax.persistence.EntityListeners;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.dom4j.Element;
 import org.hibernate.reflection.ReflectionManager;
 import org.hibernate.reflection.XClass;
@@ -40,7 +38,6 @@
  */
 public class JavaXFactory implements ReflectionManager {
 
-	private static Log log = LogFactory.getLog( JavaXFactory.class );
 	private XMLContext xmlContext;
 	private HashMap defaults;
 
@@ -146,7 +143,7 @@
 					namedQueries = new ArrayList<NamedQuery>();
 					defaults.put( NamedQuery.class, namedQueries );
 				}
-				List<NamedQuery> currentNamedQueries = EJB3OverridenAnnotationReader.buildNamedQueries(element, false);
+				List<NamedQuery> currentNamedQueries = EJB3OverridenAnnotationReader.buildNamedQueries(element, false, xmlDefaults);
 				namedQueries.addAll( currentNamedQueries );
 
 				List<NamedNativeQuery> namedNativeQueries = (List<NamedNativeQuery>) defaults.get(NamedNativeQuery.class);
@@ -154,7 +151,7 @@
 					namedNativeQueries = new ArrayList<NamedNativeQuery>();
 					defaults.put( NamedNativeQuery.class, namedNativeQueries );
 				}
-				List<NamedNativeQuery> currentNamedNativeQueries = EJB3OverridenAnnotationReader.buildNamedQueries(element, true);
+				List<NamedNativeQuery> currentNamedNativeQueries = EJB3OverridenAnnotationReader.buildNamedQueries(element, true, xmlDefaults);
 				namedNativeQueries.addAll( currentNamedNativeQueries );
 
 				List<SqlResultSetMapping> sqlResultSetMappings = (List<SqlResultSetMapping>) defaults.get(SqlResultSetMapping.class);

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/Pair.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/Pair.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/Pair.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -19,6 +19,9 @@
 
 	@Override
 	public boolean equals(Object obj) {
+		if ( ! (obj instanceof Pair) ) {
+			 return false;
+		}
 		Pair other = (Pair) obj;
 		return safeEquals( o1, other.o1 ) && safeEquals( o2, other.o2 );
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -8,7 +8,7 @@
  * @author Davide Marchignoli
  * @author Paolo Perrotta
  */
-class CompoundTypeEnvironment implements TypeEnvironment {
+public class CompoundTypeEnvironment implements TypeEnvironment {
 
 	private final TypeEnvironment f;
 
@@ -22,4 +22,23 @@
 	public Type bind(Type type) {
 		return f.bind( g.bind( type ) );
 	}
+
+	public boolean equals(Object o) {
+		if ( this == o ) return true;
+		if ( o == null || getClass() != o.getClass() ) return false;
+
+		final CompoundTypeEnvironment that = (CompoundTypeEnvironment) o;
+
+		if ( !f.equals( that.f ) ) return false;
+		if ( !g.equals( that.g ) ) return false;
+
+		return true;
+	}
+
+	public int hashCode() {
+		int result;
+		result = f.hashCode();
+		result = 29 * result + g.hashCode();
+		return result;
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/XMLContext.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/XMLContext.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/XMLContext.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -60,7 +60,7 @@
 		//entity mapping default
 		Default entityMappingDefault = new Default();
 		Element unitElement = root.element( "package" );
-		String packageName = unitElement != null ? unitElement.getTextTrim() : "";
+		String packageName = unitElement != null ? unitElement.getTextTrim() : null;
 		entityMappingDefault.setPackageName( packageName );
 		unitElement = root.element( "schema" );
 		entityMappingDefault.setSchema( unitElement != null ? unitElement.getTextTrim() : null );
@@ -135,7 +135,7 @@
 	}
 
 	public static String buildSafeClassName(String className, String defaultPackageName) {
-		if ( className.indexOf( '.' ) < 0 && defaultPackageName != null ) {
+		if ( className.indexOf( '.' ) < 0 && StringHelper.isNotEmpty( defaultPackageName ) ) {
 			className = StringHelper.qualify( defaultPackageName, className );
 		}
 		return className;
@@ -176,7 +176,12 @@
 		}
 
 		protected void setAccess(String access) {
-			this.access = access;
+			if ( "FIELD".equals( access ) || "PROPERTY".equals( access ) ) {
+				this.access = access.toLowerCase();
+			}
+			else {
+				this.access = access;
+			}
 		}
 
 		public String getCatalog() {

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/ByteArrayBlobType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/ByteArrayBlobType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/ByteArrayBlobType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -66,7 +66,7 @@
 			int length = array.length;
 			Byte[] copy = new Byte[length];
 			for ( int index = 0; index < length ; index++ ) {
-				copy[index] = new Byte( array[index].byteValue() );
+				copy[index] = Byte.valueOf( array[index].byteValue() );
 			}
 			return copy;
 		}
@@ -168,7 +168,7 @@
 		int length = bytes.length;
 		Byte[] result = new Byte[length];
 		for ( int index = 0; index < length ; index++ ) {
-			result[index] = new Byte( bytes[index] );
+			result[index] = Byte.valueOf( bytes[index] );
 		}
 		return result;
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/CharacterArrayClobType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/CharacterArrayClobType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/CharacterArrayClobType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -67,7 +67,7 @@
 			for ( int i = reader.read( charbuf ); i > 0 ; i = reader.read( charbuf ) ) {
 				result.ensureCapacity( result.size() + BUFFER_SIZE );
 				for ( int charIndex = 0; charIndex < i ; charIndex++ ) {
-					result.add( new Character( charbuf[charIndex] ) );
+					result.add( Character.valueOf( charbuf[charIndex] ) );
 				}
 			}
 		}
@@ -117,7 +117,7 @@
 			int length = array.length;
 			Character[] copy = new Character[length];
 			for ( int index = 0; index < length ; index++ ) {
-				copy[index] = new Character( array[index].charValue() );
+				copy[index] = Character.valueOf( array[index].charValue() );
 			}
 			return copy;
 		}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/EnumType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/EnumType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/type/EnumType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -18,8 +18,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.AssertionFailure;
 import org.hibernate.HibernateException;
+import org.hibernate.usertype.EnhancedUserType;
 import org.hibernate.usertype.ParameterizedType;
-import org.hibernate.usertype.UserType;
 import org.hibernate.util.ReflectHelper;
 import org.hibernate.util.StringHelper;
 
@@ -30,7 +30,7 @@
  * @author Emmanuel Bernard
  */
 //TODO implements readobject/writeobject to recalculate the enumclasses
-public class EnumType implements UserType, ParameterizedType, Serializable {
+public class EnumType implements EnhancedUserType, ParameterizedType, Serializable {
 	private static Log log = LogFactory.getLog( EnumType.class );
 	private static final boolean IS_TRACE_ENABLED;
 
@@ -119,7 +119,7 @@
 				if ( IS_TRACE_ENABLED ) {
 					log.debug( "Binding '" + ordinal + "' to parameter: " + index );
 				}
-				st.setObject( index, new Integer( ordinal ), sqlType );
+				st.setObject( index, Integer.valueOf( ordinal ), sqlType );
 			}
 			else {
 				String enumString = ( (Enum) value ).name();
@@ -324,4 +324,46 @@
 		ois.defaultReadObject();
 		initEnumValue();
 	}
+
+	public String objectToSQLString(Object value) {
+		boolean isOrdinal = isOrdinal( sqlType );
+		if ( isOrdinal ) {
+			int ordinal = ( (Enum) value ).ordinal();
+			return Integer.toString( ordinal );
+		}
+		else {
+			return '\'' + ( (Enum) value ).name() + '\'';
+		}
+	}
+
+	public String toXMLString(Object value) {
+		boolean isOrdinal = isOrdinal( sqlType );
+		if ( isOrdinal ) {
+			int ordinal = ( (Enum) value ).ordinal();
+			return Integer.toString( ordinal );
+		}
+		else {
+			return ( (Enum) value ).name();
+		}
+	}
+
+	public Object fromXMLString(String xmlValue) {
+		try {
+			int ordinal = Integer.parseInt( xmlValue );
+			Object[] values = enumValues.get( enumClass );
+			if ( values == null ) throw new AssertionFailure( "enumValues not preprocessed: " + enumClass );
+			if ( ordinal < 0 || ordinal >= values.length ) {
+				throw new IllegalArgumentException( "Unknown ordinal value for enum " + enumClass + ": " + ordinal );
+			}
+			return values[ordinal];
+		}
+		catch(NumberFormatException e) {
+			try {
+				return Enum.valueOf( enumClass, xmlValue );
+			}
+			catch (IllegalArgumentException iae) {
+				throw new IllegalArgumentException( "Unknown name value for enum " + enumClass + ": " + xmlValue, iae );
+			}
+		}
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/ClassValidator.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/ClassValidator.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/ClassValidator.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -28,7 +28,9 @@
 import org.hibernate.AssertionFailure;
 import org.hibernate.Hibernate;
 import org.hibernate.MappingException;
+import org.hibernate.validator.interpolator.DefaultMessageInterpolatorAggerator;
 import org.hibernate.cfg.annotations.Version;
+import org.hibernate.cfg.BinderHelper;
 import org.hibernate.mapping.PersistentClass;
 import org.hibernate.mapping.Property;
 import org.hibernate.reflection.Filter;
@@ -54,7 +56,6 @@
 	private static final String DEFAULT_VALIDATOR_MESSAGE = "org.hibernate.validator.resources.DefaultValidatorMessages";
 	private static final String VALIDATOR_MESSAGE = "ValidatorMessages";
 	private static final Set<Class> INDEXABLE_CLASS = new HashSet<Class>();
-	private static final ReflectionManager reflectionManager = new JavaXFactory();
 
 	static {
 		INDEXABLE_CLASS.add( Integer.class );
@@ -68,20 +69,32 @@
 
 	private final Class<T> beanClass;
 	private transient ResourceBundle messageBundle;
-	private transient boolean defaultResourceBundle;
+	private transient ResourceBundle defaultMessageBundle;
+	private transient boolean isUserProvidedResourceBundle;
+	private transient ReflectionManager reflectionManager = new JavaXFactory();
 
 	private final transient Map<XClass, ClassValidator> childClassValidators;
 	private transient List<Validator> beanValidators;
 	private transient List<Validator> memberValidators;
 	private transient List<XMember> memberGetters;
-	private transient Map<Validator, String> messages;
 	private transient List<XMember> childGetters;
+	private transient DefaultMessageInterpolatorAggerator defaultInterpolator;
+	private transient MessageInterpolator userInterpolator;
+	private static final Filter GET_ALL_FILTER = new Filter() {
+		public boolean returnStatic() {
+		return true;
+		}
 
+		public boolean returnTransient() {
+		return true;
+		}
+	};
+
 	/**
 	 * create the validator engine for this bean type
 	 */
 	public ClassValidator(Class<T> beanClass) {
-		this( beanClass, null );
+		this( beanClass, (ResourceBundle) null );
 	}
 
 	/**
@@ -89,25 +102,44 @@
 	 * for message rendering on violation
 	 */
 	public ClassValidator(Class<T> beanClass, ResourceBundle resourceBundle) {
-		this( beanClass, resourceBundle, new HashMap<XClass, ClassValidator>() );
+		this( beanClass, resourceBundle, null, new HashMap<XClass, ClassValidator>() );
 	}
 
+	/**
+	 * create the validator engine for a particular bean class, using a custom message interpolator
+	 * for message rendering on violation
+	 */
+	public ClassValidator(Class<T> beanClass, MessageInterpolator interpolator) {
+		this( beanClass, null, interpolator, new HashMap<XClass, ClassValidator>() );
+	}
+
 	protected ClassValidator(
-			Class<T> beanClass, ResourceBundle resourceBundle, Map<XClass, ClassValidator> childClassValidators
+			Class<T> beanClass, ResourceBundle resourceBundle, MessageInterpolator interpolator, Map<XClass, ClassValidator> childClassValidators
 	) {
-		this( reflectionManager.toXClass( beanClass ), resourceBundle, childClassValidators );
+		XClass beanXClass = reflectionManager.toXClass( beanClass );
+		this.beanClass = beanClass;
+		this.messageBundle = resourceBundle == null ?
+				getDefaultResourceBundle() :
+				resourceBundle;
+		this.defaultMessageBundle = ResourceBundle.getBundle( DEFAULT_VALIDATOR_MESSAGE );
+		this.userInterpolator = interpolator;
+		this.childClassValidators = childClassValidators;
+		initValidator( beanXClass, childClassValidators );
 	}
 
 	@SuppressWarnings("unchecked")
 	protected ClassValidator(
-			XClass beanClass, ResourceBundle resourceBundle, Map<XClass, ClassValidator> childClassValidators
+			XClass beanXClass, ResourceBundle resourceBundle, MessageInterpolator userInterpolator,
+			Map<XClass, ClassValidator> childClassValidators
 	) {
-		this.beanClass = reflectionManager.toClass( beanClass );
+		this.beanClass = reflectionManager.toClass( beanXClass );
 		this.messageBundle = resourceBundle == null ?
 				getDefaultResourceBundle() :
 				resourceBundle;
+		this.defaultMessageBundle = ResourceBundle.getBundle( DEFAULT_VALIDATOR_MESSAGE );
+		this.userInterpolator = userInterpolator;
 		this.childClassValidators = childClassValidators;
-		initValidator( beanClass, childClassValidators, this.messageBundle );
+		initValidator( beanXClass, childClassValidators );
 	}
 
 	private ResourceBundle getDefaultResourceBundle() {
@@ -139,22 +171,22 @@
 						"ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to " + DEFAULT_VALIDATOR_MESSAGE
 				);
 				//the user did not override the default ValidatorMessages
-				rb = ResourceBundle.getBundle( DEFAULT_VALIDATOR_MESSAGE );
+				rb = null;
 			}
 		}
-		defaultResourceBundle = true;
+		isUserProvidedResourceBundle = true;
 		return rb;
 	}
 
 	private void initValidator(
-			XClass xClass, Map<XClass, ClassValidator> childClassValidators,
-			ResourceBundle resourceBundle
+			XClass xClass, Map<XClass, ClassValidator> childClassValidators
 	) {
 		beanValidators = new ArrayList<Validator>();
 		memberValidators = new ArrayList<Validator>();
 		memberGetters = new ArrayList<XMember>();
-		messages = new HashMap<Validator, String>();
 		childGetters = new ArrayList<XMember>();
+		defaultInterpolator = new DefaultMessageInterpolatorAggerator();
+		defaultInterpolator.initialize( messageBundle, defaultMessageBundle );
 
 		//build the class hierarchy to look for members in
 		childClassValidators.put( xClass, this );
@@ -174,23 +206,15 @@
 			List<XMethod> methods = currClass.getDeclaredMethods();
 			for ( XMethod method : methods ) {
 				createMemberValidator( method );
-				createChildValidator( resourceBundle, method );
+				createChildValidator( method );
 			}
 
 			List<XProperty> fields = currClass.getDeclaredProperties(
-					"field", new Filter() {
-				public boolean returnStatic() {
-					return true;
-				}
-
-				public boolean returnTransient() {
-					return true;
-				}
-			}
+					"field", GET_ALL_FILTER
 			);
 			for ( XProperty field : fields ) {
 				createMemberValidator( field );
-				createChildValidator( resourceBundle, field );
+				createChildValidator( field );
 			}
 		}
 	}
@@ -206,7 +230,7 @@
 	}
 
 	@SuppressWarnings("unchecked")
-	private void createChildValidator(ResourceBundle resourceBundle, XMember member) {
+	private void createChildValidator( XMember member) {
 		if ( member.isAnnotationPresent( Valid.class ) ) {
 			setAccessible( member );
 			childGetters.add( member );
@@ -218,15 +242,13 @@
 				clazz = member.getType();
 			}
 			if ( !childClassValidators.containsKey( clazz ) ) {
-				new ClassValidator( clazz, resourceBundle, childClassValidators );
+				new ClassValidator( clazz, messageBundle, userInterpolator, childClassValidators );
 			}
 		}
 	}
 
 	private void createMemberValidator(XMember member) {
-		if ( !member.isTypeResolved() ) {
-			log.warn( "Original type of property " + member + " is unbound and has been approximated." );
-		}
+		boolean validatorPresent = false;
 		Annotation[] memberAnnotations = member.getAnnotations();
 		for ( int j = 0; j < memberAnnotations.length ; j++ ) {
 			Annotation methodAnnotation = memberAnnotations[j];
@@ -235,8 +257,12 @@
 				memberValidators.add( propertyValidator );
 				setAccessible( member );
 				memberGetters.add( member );
+				validatorPresent = true;
 			}
 		}
+		if ( validatorPresent && !member.isTypeResolved() ) {
+			log.warn( "Original type of property " + member + " is unbound and has been approximated." );
+		}
 	}
 
 	private static void setAccessible(XMember member) {
@@ -254,11 +280,7 @@
 			}
 			Validator beanValidator = validatorClass.value().newInstance();
 			beanValidator.initialize( annotation );
-			String messageTemplate = (String) annotation.getClass()
-					.getMethod( "message", (Class[]) null )
-					.invoke( annotation );
-			String message = replace( messageTemplate, annotation );
-			messages.put( beanValidator, message );
+			defaultInterpolator.addInterpolator( annotation, beanValidator );
 			return beanValidator;
 		}
 		catch (Exception e) {
@@ -300,7 +322,7 @@
 		for ( int i = 0; i < beanValidators.size() ; i++ ) {
 			Validator validator = beanValidators.get( i );
 			if ( !validator.isValid( bean ) ) {
-				results.add( new InvalidValue( messages.get( validator ), beanClass, null, bean, bean ) );
+				results.add( new InvalidValue( interpolate(validator), beanClass, null, bean, bean ) );
 			}
 		}
 
@@ -311,7 +333,7 @@
 				Validator validator = memberValidators.get( i );
 				if ( !validator.isValid( value ) ) {
 					String propertyName = getPropertyName( getter );
-					results.add( new InvalidValue( messages.get( validator ), beanClass, propertyName, value, bean ) );
+					results.add( new InvalidValue( interpolate(validator), beanClass, propertyName, value, bean ) );
 				}
 			}
 		}
@@ -391,6 +413,16 @@
 		return results.toArray( new InvalidValue[results.size()] );
 	}
 
+	private String interpolate(Validator validator) {
+		String message = defaultInterpolator.getAnnotationMessage( validator );
+		if (userInterpolator != null) {
+			return userInterpolator.interpolate( message, validator, defaultInterpolator );
+		}
+		else {
+			return defaultInterpolator.interpolate( message, validator, null);
+		}
+	}
+
 	@SuppressWarnings("unchecked")
 	private ClassValidator getClassValidator(Object value) {
 		Class clazz = value.getClass();
@@ -415,7 +447,7 @@
 				Object value = getMemberValue( bean, getter );
 				Validator validator = memberValidators.get( i );
 				if ( !validator.isValid( value ) ) {
-					results.add( new InvalidValue( messages.get( validator ), beanClass, propertyName, value, bean ) );
+					results.add( new InvalidValue( interpolate(validator), beanClass, propertyName, value, bean ) );
 				}
 			}
 		}
@@ -437,7 +469,7 @@
 			if ( getPropertyName( getter ).equals( propertyName ) ) {
 				Validator validator = memberValidators.get( i );
 				if ( !validator.isValid( value ) ) {
-					results.add( new InvalidValue( messages.get( validator ), beanClass, propertyName, value, null ) );
+					results.add( new InvalidValue( interpolate(validator), beanClass, propertyName, value, null ) );
 				}
 			}
 		}
@@ -478,6 +510,7 @@
 		return propertyName;
 	}
 
+	/** @deprecated */
 	private String replace(String message, Annotation parameters) {
 		StringTokenizer tokens = new StringTokenizer( message, "#{}", true );
 		StringBuilder buf = new StringBuilder( 30 );
@@ -514,8 +547,26 @@
 						throw new IllegalArgumentException( "could not render message", e );
 					}
 				}
-				else if ( messageBundle != null ) {
-					String string = messageBundle.getString( token );
+				else {
+					String string = null;
+					try {
+						string = messageBundle != null ? messageBundle.getString( token ) : null;
+					}
+					catch( MissingResourceException e ) {
+						//give a second chance with the default resource bundle
+					}
+					if (string == null) {
+						try {
+							string = defaultMessageBundle.getString( token );
+						}
+						catch( MissingResourceException e) {
+							throw new MissingResourceException(
+									"Can't find resource in validator bundles, key " + token,
+                                    defaultMessageBundle.getClass().getName(),
+                                    token
+							);
+						}
+					}
 					if ( string != null ) buf.append( replace( string, parameters ) );
 				}
 			}
@@ -543,11 +594,10 @@
 			String propertyName = getPropertyName( getters.next() );
 			if ( validator instanceof PropertyConstraint ) {
 				try {
-					Property property = persistentClass.getIdentifierProperty();
-					if ( property == null || ! propertyName.equals( property.getName() ) ) {
-						property = persistentClass.getProperty( propertyName );
+					Property property = BinderHelper.findPropertyByName(persistentClass, propertyName);
+					if (property != null) {
+						( (PropertyConstraint) validator ).apply( property );
 					}
-					( (PropertyConstraint) validator ).apply( property );
 				}
 				catch (MappingException pnfe) {
 					//do nothing
@@ -566,23 +616,34 @@
 
 	private void writeObject(ObjectOutputStream oos) throws IOException {
 		ResourceBundle rb = messageBundle;
+		MessageInterpolator interpolator = this.userInterpolator;
 		if ( rb != null && ! ( rb instanceof Serializable ) ) {
 			messageBundle = null;
-			if ( ! defaultResourceBundle ) {
+			if ( ! isUserProvidedResourceBundle ) {
 				log.warn(
-						"Serializing a ClassValidator with a not serializable ResourceBundle: ResourceBundle ignored"
+						"Serializing a ClassValidator with a non serializable ResourceBundle: ResourceBundle ignored"
 				);
 			}
 		}
+		if (interpolator != null && ! (interpolator instanceof Serializable) ) {
+			userInterpolator = null;
+			log.warn( "Serializing a non serializable MessageInterpolator" );
+		}
 		oos.defaultWriteObject();
 		oos.writeObject( messageBundle );
+		oos.writeObject( userInterpolator );
 		messageBundle = rb;
+		userInterpolator = interpolator;
 	}
 
 	private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
 		ois.defaultReadObject();
 		ResourceBundle rb = (ResourceBundle) ois.readObject();
 		if ( rb == null ) rb = getDefaultResourceBundle();
-		initValidator( reflectionManager.toXClass( beanClass ), new HashMap<XClass, ClassValidator>(), rb );
+		this.messageBundle = rb;
+		this.userInterpolator = (MessageInterpolator) ois.readObject();
+		this.defaultMessageBundle = ResourceBundle.getBundle( DEFAULT_VALIDATOR_MESSAGE );
+		reflectionManager = new JavaXFactory();
+		initValidator( reflectionManager.toXClass( beanClass ), new HashMap<XClass, ClassValidator>() );
 	}
 }

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/Environment.java (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/validator/Environment.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/MaxValidator.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/MaxValidator.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/MaxValidator.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,6 +2,8 @@
 package org.hibernate.validator;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
 
 import org.hibernate.mapping.Column;
 import org.hibernate.mapping.Property;
@@ -24,8 +26,7 @@
 		if ( value == null ) return true;
 		if ( value instanceof String ) {
 			try {
-				double dv = Double.parseDouble( (String) value );
-				return dv <= max;
+				return new BigDecimal( (String) value ).compareTo( BigDecimal.valueOf( max ) ) <= 0;
 			}
 			catch (NumberFormatException nfe) {
 				return false;
@@ -35,6 +36,12 @@
 			double dv = ( (Number) value ).doubleValue();
 			return dv <= max;
 		}
+		else if ( value instanceof BigInteger ) {
+			return ( (BigInteger) value ).compareTo( BigInteger.valueOf( max ) ) <= 0;
+		}
+		else if ( value instanceof BigDecimal ) {
+			return ( (BigDecimal) value ).compareTo( BigDecimal.valueOf( max ) ) <= 0;
+		}
 		else if ( value instanceof Number ) {
 			long lv = ( (Number) value ).longValue();
 			return lv <= max;

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/MessageInterpolator.java (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/validator/MessageInterpolator.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/MinValidator.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/MinValidator.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/MinValidator.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,6 +2,8 @@
 package org.hibernate.validator;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
 
 import org.hibernate.mapping.Column;
 import org.hibernate.mapping.Property;
@@ -24,8 +26,7 @@
 		if ( value == null ) return true;
 		if ( value instanceof String ) {
 			try {
-				double dv = Double.parseDouble( (String) value );
-				return dv >= min;
+				return new BigDecimal( (String) value ).compareTo( BigDecimal.valueOf(min) ) >= 0;
 			}
 			catch (NumberFormatException nfe) {
 				return false;
@@ -35,6 +36,12 @@
 			double dv = ( (Number) value ).doubleValue();
 			return dv >= min;
 		}
+		else if ( value instanceof BigInteger ) {
+			return ( (BigInteger) value ).compareTo( BigInteger.valueOf( min ) ) >= 0;
+		}
+		else if ( value instanceof BigDecimal ) {
+			return ( (BigDecimal) value ).compareTo( BigDecimal.valueOf( min ) ) >= 0;
+		}
 		else if ( value instanceof Number ) {
 			long lv = ( (Number) value ).longValue();
 			return lv >= min;

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/RangeValidator.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/RangeValidator.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/RangeValidator.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,6 +2,7 @@
 package org.hibernate.validator;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 
 import org.hibernate.mapping.Column;
 import org.hibernate.mapping.Property;
@@ -24,8 +25,8 @@
 		if ( value == null ) return true;
 		if ( value instanceof String ) {
 			try {
-				double dv = Double.parseDouble( (String) value );
-				return dv >= min && dv <= max;
+				BigDecimal dv = new BigDecimal( (String) value );
+				return dv.compareTo( BigDecimal.valueOf( min ) ) >= 0 && dv.compareTo( BigDecimal.valueOf( max ) ) <= 0;
 			}
 			catch (NumberFormatException nfe) {
 				return false;

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/event/ValidateEventListener.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/event/ValidateEventListener.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/event/ValidateEventListener.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -11,6 +11,9 @@
 
 import org.hibernate.AssertionFailure;
 import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.util.StringHelper;
+import org.hibernate.util.ReflectHelper;
 import org.hibernate.cfg.Configuration;
 import org.hibernate.event.Initializable;
 import org.hibernate.event.PreInsertEvent;
@@ -26,6 +29,8 @@
 import org.hibernate.validator.ClassValidator;
 import org.hibernate.validator.InvalidStateException;
 import org.hibernate.validator.InvalidValue;
+import org.hibernate.validator.Environment;
+import org.hibernate.validator.MessageInterpolator;
 
 /**
  * Before insert and update, executes the validator framework
@@ -42,11 +47,32 @@
 	@SuppressWarnings("unchecked")
 	public synchronized void initialize(final Configuration cfg) {
 		if ( !isInitialized ) {
+			String interpolatorString = cfg.getProperty( Environment.MESSAGE_INTERPOLATOR_CLASS );
+			MessageInterpolator interpolator = null;
+			if ( StringHelper.isNotEmpty( interpolatorString ) ) {
+				try {
+					Class interpolatorClass = ReflectHelper.classForName( interpolatorString );
+					interpolator = (MessageInterpolator) interpolatorClass.newInstance();
+				}
+				catch (ClassNotFoundException e) {
+					throw new HibernateException( "Unable to find message interpolator: " + interpolatorString, e );
+				}
+				catch (IllegalAccessException e) {
+					throw new HibernateException( "Unable to instanciate message interpolator: " + interpolatorString, e );
+				}
+				catch (InstantiationException e) {
+					throw new HibernateException( "Unable to instanciate message interpolator: " + interpolatorString, e );
+				}
+				catch (ClassCastException e) {
+					throw new HibernateException( "Class does not implement "
+						+ MessageInterpolator.class.getName() + ": " + interpolatorString, e );
+				}
+			}
 			Iterator<PersistentClass> classes = (Iterator<PersistentClass>) cfg.getClassMappings();
 			while ( classes.hasNext() ) {
 				PersistentClass clazz = classes.next();
 				final Class mappedClass = clazz.getMappedClass();
-				ClassValidator validator = new ClassValidator( mappedClass );
+				ClassValidator validator = new ClassValidator( mappedClass, interpolator );
 				ValidatableElement element = new ValidatableElement( mappedClass, validator );
 				addSubElement( clazz.getIdentifierProperty(), element );
 				Iterator properties = clazz.getPropertyIterator();
@@ -97,12 +123,15 @@
 		InvalidValue[] invalidValues = element.validator == null ?
 				null :
 				element.validator.getInvalidValues( entity );
-		for ( InvalidValue invalidValue : invalidValues ) {
-			consolidatedInvalidValues.add( invalidValue );
+		if (invalidValues != null) {
+			for ( InvalidValue invalidValue : invalidValues ) {
+				consolidatedInvalidValues.add( invalidValue );
+			}
 		}
 		if ( consolidatedInvalidValues.size() > 0 ) {
 			throw new InvalidStateException(
-					consolidatedInvalidValues.toArray( new InvalidValue[]{} ), entity.getClass().getName()
+					consolidatedInvalidValues.toArray( new InvalidValue[consolidatedInvalidValues.size()] ),
+					entity.getClass().getName()
 			);
 		}
 	}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolator.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolator.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolator.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,135 +0,0 @@
-//$Id: $
-package org.hibernate.validator.interpolator;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.StringTokenizer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.util.StringHelper;
-import org.hibernate.validator.MessageInterpolator;
-import org.hibernate.validator.Validator;
-
-/**
- * Resource bundle based interpolator
- * Also interpolate annotation parameters inside the message
- *
- * @author Emmanuel Bernard
- */
-public class DefaultMessageInterpolator implements MessageInterpolator, Serializable {
-	private static Log log = LogFactory.getLog( DefaultMessageInterpolator.class );
-	private Map<String, Object> annotationParameters = new HashMap<String, Object>();
-	private transient ResourceBundle messageBundle;
-	private transient ResourceBundle defaultMessageBundle;
-	private String annotationMessage;
-	private String interpolateMessage;
-
-	//not an interface method
-	public void initialize(ResourceBundle messageBundle, ResourceBundle defaultMessageBundle) {
-		this.messageBundle = messageBundle;
-		this.defaultMessageBundle = defaultMessageBundle;
-	}
-
-	public void initialize(Annotation annotation, MessageInterpolator defaultInterpolator) {
-		Class clazz = annotation.getClass();
-		for ( Method method  : clazz.getMethods() ) {
-			try {
-				//FIXME remove non serilalization elements on writeObject?
-				if ( method.getReturnType() != void.class
-						&& method.getParameterTypes().length == 0
-						&& ! Modifier.isStatic( method.getModifiers() ) ) {
-					//cannot use an exclude list because the parameter name could match a method name
-					annotationParameters.put( method.getName(), method.invoke( annotation ) );
-				}
-			}
-			catch (IllegalAccessException e) {
-				//really should not happen, but we degrade nicely
-				log.warn( "Unable to access " + StringHelper.qualify( clazz.toString(), method.getName() ) );
-			}
-			catch (InvocationTargetException e) {
-				//really should not happen, but we degrade nicely
-				log.warn( "Unable to access " + StringHelper.qualify( clazz.toString(), method.getName() ) );
-			}
-		}
-		annotationMessage = (String) annotationParameters.get( "message" );
-		if (annotationMessage == null) {
-			throw new IllegalArgumentException( "Annotation " + clazz + " does not have an (accessible) message attribute");
-		}
-		interpolateMessage = replace( annotationMessage );
-	}
-
-	private String replace(String message) {
-		StringTokenizer tokens = new StringTokenizer( message, "#{}", true );
-		StringBuilder buf = new StringBuilder( 30 );
-		boolean escaped = false;
-		boolean el = false;
-		while ( tokens.hasMoreTokens() ) {
-			String token = tokens.nextToken();
-			if ( !escaped && "#".equals( token ) ) {
-				el = true;
-			}
-			if ( !el && "{".equals( token ) ) {
-				escaped = true;
-			}
-			else if ( escaped && "}".equals( token ) ) {
-				escaped = false;
-			}
-			else if ( !escaped ) {
-				if ( "{".equals( token ) ) el = false;
-				buf.append( token );
-			}
-			else {
-				Object variable = annotationParameters.get( token );
-				if ( variable != null ) {
-					buf.append( variable );
-				}
-				else {
-					String string = null;
-					try {
-						string = messageBundle != null ? messageBundle.getString( token ) : null;
-					}
-					catch( MissingResourceException e ) {
-						//give a second chance with the default resource bundle
-					}
-					if (string == null) {
-						try {
-							string = defaultMessageBundle.getString( token );
-						}
-						catch( MissingResourceException e) {
-							throw new MissingResourceException(
-									"Can't find resource in validator bundles, key " + token,
-									defaultMessageBundle.getClass().getName(),
-									token
-							);
-						}
-					}
-					if ( string != null ) buf.append( replace( string ) );
-				}
-			}
-		}
-		return buf.toString();
-	}
-
-	public String interpolate(String message, Validator validator, MessageInterpolator defaultInterpolator) {
-		if ( annotationMessage.equals( message ) ) {
-			//short cut
-			return interpolateMessage;
-		}
-		else {
-			//TODO keep them in a weak hash map, but this might not even be useful
-			return replace( message );
-		}
-	}
-
-	public String getAnnotationMessage() {
-		return annotationMessage;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolator.java (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolator.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolatorAggerator.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolatorAggerator.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolatorAggerator.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,57 +0,0 @@
-//$Id: $
-package org.hibernate.validator.interpolator;
-
-import java.lang.annotation.Annotation;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ResourceBundle;
-import java.io.Serializable;
-
-import org.hibernate.validator.MessageInterpolator;
-import org.hibernate.validator.Validator;
-import org.hibernate.AssertionFailure;
-
-/**
- * @author Emmanuel Bernard
- */
-public class DefaultMessageInterpolatorAggerator implements MessageInterpolator, Serializable {
-	private Map<Validator, DefaultMessageInterpolator> interpolators = new HashMap<Validator, DefaultMessageInterpolator>();
-	//transient but repopulated by the object owing a reference to the interpolator
-	private transient ResourceBundle messageBundle;
-	//transient but repopulated by the object owing a reference to the interpolator
-	private transient ResourceBundle defaultMessageBundle;
-
-	//not an interface method
-	public void initialize(ResourceBundle messageBundle, ResourceBundle defaultMessageBundle) {
-		this.messageBundle = messageBundle;
-		this.defaultMessageBundle = defaultMessageBundle;
-		//useful when we deserialize
-		for ( DefaultMessageInterpolator interpolator : interpolators.values() ) {
-			interpolator.initialize( messageBundle, defaultMessageBundle );
-		}
-	}
-
-	public void addInterpolator(Annotation annotation, Validator validator) {
-		DefaultMessageInterpolator interpolator = new DefaultMessageInterpolator();
-		interpolator.initialize(messageBundle, defaultMessageBundle );
-		interpolator.initialize( annotation, null );
-		interpolators.put( validator, interpolator );
-	}
-
-	public String interpolate(String message, Validator validator, MessageInterpolator defaultInterpolator) {
-		DefaultMessageInterpolator defaultMessageInterpolator = interpolators.get( validator );
-		if (defaultMessageInterpolator == null) {
-			return message;
-		}
-		else {
-			return defaultMessageInterpolator.interpolate( message, validator, defaultInterpolator );
-		}
-	}
-
-	public String getAnnotationMessage(Validator validator) {
-		DefaultMessageInterpolator defaultMessageInterpolator = interpolators.get( validator );
-		String message = defaultMessageInterpolator != null ? defaultMessageInterpolator.getAnnotationMessage() : null;
-		if (message == null) throw new AssertionFailure("Validator not registred to the messageInterceptorAggregator");
-		return message;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolatorAggerator.java (from rev 10565, trunk/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolatorAggerator.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages.properties
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages.properties	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages.properties	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,16 +1,4 @@
-#generic of Hibernate Validator
-validator.assertFalse=assertion failed
-validator.assertTrue=assertion failed
-validator.future=must be a future date
-validator.length=length must be between {min} and {max}
-validator.max=must less than or equal to {value}
-validator.min=must greater than or equal to {value}
-validator.notNull=may not be null
-validator.past=must be a past date
-validator.pattern=must match "{regex}"
-validator.range=must be between {min} and {max}
-validator.size=size must be between {min} and {max}
-validator.email=not a well-formed email address
+#overriding of default keys
 
 #specific to my project
 long=is too damn long

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages_da.properties
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages_da.properties	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages_da.properties	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,12 +1,7 @@
-validator.assertFalse=assertion fejlet
-validator.assertTrue=assertion fejlet
-validator.future=skal være en fremtidig dato
-validator.length=længden skal være mellem {min} og {max}
-validator.max=skal være mindre end eller lig med {value}
-validator.min=skal være større end eller lig med {value}
-validator.notNull=må ikke være null
-validator.past=skal være en passeret dato
-validator.pattern=skal matche "{regex}"
-validator.range=skal være mellem {min} og {max}
-validator.size=antallet skal være mellem {min} og {max}
-validator.email=not a well-formed email address
\ No newline at end of file
+#overriding of default keys
+
+#specific to my project
+long=is too damn long
+floor.name=Floor
+out.of.range=lower that {min} and greater than {max}
+floor.out.of.range={floor.name} cannot be {out.of.range}
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages_fr.properties
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages_fr.properties	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/ValidatorMessages_fr.properties	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,15 +1,4 @@
-validator.assertFalse=l'assertion a échoué
-validator.assertTrue=l'assertion a échoué
-validator.future=doit être dans le futur
-validator.length=la longueur doit être entre {min} et {max}
-validator.max=doit être inférieur ou égal à {value}
-validator.min=doit être supérieur ou égal à {value}
-validator.notNull=ne peut pas être nul
-validator.past=doit être dans le passé
-validator.pattern=doit suivre "{regex}"
-validator.range=doit être entre {min} et {max}
-validator.size=le nombre d'éléments doit être entre {min} et {max}
-validator.email=adresse email non valide
+#overriding of default keys
 
 #specific to my project
 long=est grave trop long

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,72 +1,72 @@
-//$Id: Document.java 10014 2006-06-12 09:56:27 -0700 (lun., 12 juin 2006) epbernard $
-package org.hibernate.lucene.test;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-
-import org.hibernate.lucene.Indexed;
-import org.hibernate.lucene.Keyword;
-import org.hibernate.lucene.Text;
-import org.hibernate.lucene.Unstored;
-import org.hibernate.lucene.Boost;
-
- at Entity
- at Indexed(index = "Documents")
-public class Document {
-	private Long id;
-	private String title;
-	private String summary;
-	private String text;
-
-	Document() {
-	}
-
-	public Document(String title, String summary, String text) {
-		super();
-		this.summary = summary;
-		this.text = text;
-		this.title = title;
-	}
-
-	@Id
-	@GeneratedValue
-	@Keyword(id = true)
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	@Text
-	@Boost(2)
-	public String getTitle() {
-		return title;
-	}
-
-	public void setTitle(String title) {
-		this.title = title;
-	}
-
-	@Unstored(name = "Abstract")
-	public String getSummary() {
-		return summary;
-	}
-
-	public void setSummary(String summary) {
-		this.summary = summary;
-	}
-
-	@Lob
-	@Unstored
-	public String getText() {
-		return text;
-	}
-
-	public void setText(String text) {
-		this.text = text;
-	}
-}
+//$Id$
+package org.hibernate.lucene.test;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+
+import org.hibernate.lucene.Indexed;
+import org.hibernate.lucene.Keyword;
+import org.hibernate.lucene.Text;
+import org.hibernate.lucene.Unstored;
+import org.hibernate.lucene.Boost;
+
+ at Entity
+ at Indexed(index = "Documents")
+public class Document {
+	private Long id;
+	private String title;
+	private String summary;
+	private String text;
+
+	Document() {
+	}
+
+	public Document(String title, String summary, String text) {
+		super();
+		this.summary = summary;
+		this.text = text;
+		this.title = title;
+	}
+
+	@Id
+	@GeneratedValue
+	@Keyword(id = true)
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	@Text
+	@Boost(2)
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	@Unstored(name = "Abstract")
+	public String getSummary() {
+		return summary;
+	}
+
+	public void setSummary(String summary) {
+		this.summary = summary;
+	}
+
+	@Lob
+	@Unstored
+	public String getText() {
+		return text;
+	}
+
+	public void setText(String text) {
+		this.text = text;
+	}
+}


Property changes on: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/PackageLevelTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/PackageLevelTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/PackageLevelTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,38 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations;
-
-import org.hibernate.Session;
-
-/**
- * @author Emmanuel Bernard
- */
-public class PackageLevelTest extends TestCase {
-
-	/**
-	 * @param x
-	 */
-	public PackageLevelTest(String x) {
-		super( x );
-	}
-
-	/**
-	 * @see org.hibernate.test.annotations.TestCase#getMappings()
-	 */
-	protected Class[] getMappings() {
-		return new Class[]{};
-	}
-
-	protected String[] getAnnotatedPackages() {
-		return new String[]{
-				"org.hibernate.test.annotations",
-				"org.hibernate.test.annotations.duplicatedgenerator",
-				"org.hibernate.test.annotations.wrongoremptypackage",
-		};
-	}
-
-	public void testDuplicatedGenerator() throws Exception {
-		Session s = openSession();
-		s.close();
-	}
-
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Hammer.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Hammer.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Hammer.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,21 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.bytecode;
-
-/**
- * @author Emmanuel Bernard
- */
-public class Hammer implements Tool {
-	private Long id;
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public Integer usage() {
-		return 0;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Hammer.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Hammer.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/ProxyBreakingTest.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/ProxyBreakingTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/ProxyBreakingTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,52 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.bytecode;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
-import org.hibernate.test.annotations.TestCase;
-import org.hibernate.cfg.Configuration;
-
-/**
- * @author Emmanuel Bernard
- */
-public class ProxyBreakingTest extends TestCase {
-
-	static {
-		System.setProperty( "hibernate.bytecode.provider", "javassist" );
-	}
-
-	public void testProxiedBridgeMethod() throws Exception {
-		//bridge methods should not be proxied
-		Session s = openSession();
-		Transaction tx = s.beginTransaction();
-		Hammer h = new Hammer();
-		s.save(h);
-		s.flush();
-		s.clear();
-		assertNotNull( "The proxy creation failure is breaking things", h.getId() );
-		h = (Hammer) s.load( Hammer.class, h.getId() );
-		assertFalse( Hibernate.isInitialized( h ) );
-		tx.rollback();
-		s.close();
-	}
-
-	public ProxyBreakingTest(String name) {
-		super( name );
-	}
-
-	protected Class[] getMappings() {
-		return new Class[0];
-	}
-
-	protected String[] getXmlFiles() {
-		return new String[] {
-				"annotations/bytecode/Hammer.hbm.xml"
-		};
-	}
-
-	@Override
-	protected void configure(Configuration cfg) {
-		super.configure( cfg.setProperty( "hibernate.bytecode.provider", "javassist" ) );
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/ProxyBreakingTest.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/ProxyBreakingTest.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Tool.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Tool.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Tool.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,13 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.bytecode;
-
-/**
- * @author Emmanuel Bernard
- */
-public interface Tool {
-	public Long getId();
-
-	public void setId(Long id);
-
-	public Number usage();
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Tool.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/Tool.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/hammer.hbm.xml
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/hammer.hbm.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/hammer.hbm.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,12 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.hibernate.test.annotations.bytecode">
-    <class name="Hammer">
-        <id name="id" type="java.lang.Long">
-            <generator class="increment"/>
-        </id>
-    </class>
-</hibernate-mapping>
\ No newline at end of file

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/hammer.hbm.xml (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/bytecode/hammer.hbm.xml)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/Boy.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/Boy.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/Boy.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -26,7 +26,8 @@
 @Entity
 @AttributeOverrides({
 		@AttributeOverride( name="characters.element", column = @Column(name="character") ),
-		@AttributeOverride( name="scorePerNickName.element", column = @Column(name="fld_score") )}
+		@AttributeOverride( name="scorePerNickName.element", column = @Column(name="fld_score") ),
+		@AttributeOverride( name="favoriteToys.element.brand.surname", column = @Column(name = "fld_surname"))}
 )
 public class Boy {
 	private Integer id;

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/Brand.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/Brand.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/Brand.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -9,6 +9,7 @@
 @Embeddable
 public class Brand {
 	private String name;
+	private String surname;
 
 	public String getName() {
 		return name;
@@ -18,6 +19,14 @@
 		this.name = name;
 	}
 
+	public String getSurname() {
+		return surname;
+	}
+
+	public void setSurname(String surname) {
+		this.surname = surname;
+	}
+
 	public boolean equals(Object o) {
 		if ( this == o ) return true;
 		if ( o == null || getClass() != o.getClass() ) return false;

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,6 +1,8 @@
 //$Id$
 package org.hibernate.test.annotations.collectionelement;
 
+import java.util.List;
+
 import org.hibernate.Session;
 import org.hibernate.Transaction;
 import org.hibernate.test.annotations.Country;
@@ -45,6 +47,9 @@
 		assertNotNull( boy.getFavoriteNumbers() );
 		assertEquals( 3, boy.getFavoriteNumbers()[1] );
 		assertTrue( boy.getCharacters().contains( Character.CRAFTY ) );
+		List result = s.createQuery( "select boy from Boy boy join boy.nickNames names where names = :name")
+				.setParameter( "name", "Thing").list();
+		assertEquals( 1, result.size() );
 		s.delete( boy );
 		tx.commit();
 		s.close();

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/duplicatedgenerator/DuplicateTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/duplicatedgenerator/DuplicateTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/duplicatedgenerator/DuplicateTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -16,6 +16,8 @@
 		try {
 			cfg.addAnnotatedClass( Flight.class );
 			cfg.addAnnotatedClass( org.hibernate.test.annotations.Flight.class );
+			cfg.addResource( "org/hibernate/test/annotations/orm.xml");
+			cfg.addResource( "org/hibernate/test/annotations/duplicatedgenerator/orm.xml");
 			cfg.buildSessionFactory();
 			fail( "Should not be able to map the same entity name twice" );
 		}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/duplicatedgenerator/orm.xml (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/duplicatedgenerator/orm.xml)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/duplicatedgenerator/package-info.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/duplicatedgenerator/package-info.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/duplicatedgenerator/package-info.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,13 +0,0 @@
-/**
- * Test package for metatata facilities
- * It contains an example of package level metadata
- */
- at javax.persistence.TableGenerator(
-		name = "EMP_GEN",
-		table = "GENERATOR_TABLE",
-		pkColumnName = "key",
-		valueColumnName = "hi",
-		pkColumnValue = "EMP",
-		allocationSize = 20
-) package org.hibernate.test.annotations.duplicatedgenerator;
-

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/entity/Java5FeaturesTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/entity/Java5FeaturesTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/entity/Java5FeaturesTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -50,7 +50,12 @@
 
 		s = openSession();
 		tx = s.beginTransaction();
-		bid = (Bid) s.get( Bid.class, bid.getId() );
+		//bid = (Bid) s.get( Bid.class, bid.getId() );
+		bid = (Bid)s.createQuery( "select b from Bid b where b.note = " +
+				Starred.class.getName() + ".OK and b.editorsNote = " +
+				Starred.class.getName() + ".GOOD and b.id = :id")
+				.setParameter( "id", bid.getId() ).uniqueResult();
+		//testing constant value
 		assertEquals( Starred.OK, bid.getNote() );
 		assertEquals( Starred.GOOD, bid.getEditorsNote() );
 		bid.setNote( null );

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/Gene.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/Gene.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/Gene.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -5,14 +5,26 @@
 import javax.persistence.Id;
 import javax.persistence.ManyToOne;
 
+import org.hibernate.annotations.Type;
+
 /**
  * @author Paolo Perrotta
  */
 @Entity
-public class Gene<T> {
+public class Gene<T, STE extends Enum> {
 
 	private Integer id;
+	private STE state;
 
+	@Type(type="org.hibernate.test.annotations.generics.StateType")
+	public STE getState() {
+		return state;
+	}
+
+	public void setState(STE state) {
+		this.state = state;
+	}
+
 	@Id
 	@GeneratedValue
 	public Integer getId() {

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/State.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/State.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/StateType.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/StateType.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -19,6 +19,20 @@
 		s.close();
 	}
 
+	public void testAcceptsUnresolvedPropertyTypesIfATypeExplicitlySet() {
+		Session s = openSession();
+		Transaction tx = s.beginTransaction();
+		Gene item = new Gene();
+		item.setState( State.DORMANT );
+		s.persist( item );
+		s.flush();
+		s.clear();
+		item = (Gene) s.get( Gene.class, item.getId() );
+		assertEquals( State.DORMANT, item.getState() );
+		tx.rollback();
+		s.close();
+	}
+
 	@Override
 	protected Class[] getMappings() {
 		return new Class[]{

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Child.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Child.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Child.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,27 +0,0 @@
-package org.hibernate.test.annotations.genericsinheritance;
-
-import javax.persistence.MappedSuperclass;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-
- at MappedSuperclass
-public abstract class Child<P extends Parent> {
-
-	@Id Long id;
-	@ManyToOne P parent;
-	
-	public Long getId() {
-		return id;
-	}
-	public void setId(Long id) {
-		this.id = id;
-	}
-	public P getParent() {
-		return parent;
-	}
-	public void setParent(P parent) {
-		this.parent = parent;
-	}
-	
-	
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Child.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Child.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy1.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy1.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy1.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,8 +0,0 @@
-package org.hibernate.test.annotations.genericsinheritance;
-
-import javax.persistence.Entity;
-
- at Entity
-public class ChildHierarchy1 extends Child<ParentHierarchy1> {
-
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy1.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy1.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy2.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy2.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy2.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,8 +0,0 @@
-package org.hibernate.test.annotations.genericsinheritance;
-
-import javax.persistence.MappedSuperclass;
-
- at MappedSuperclass
-public class ChildHierarchy2<P extends ParentHierarchy2> extends Child<P> {
-
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy2.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy2.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy22.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy22.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy22.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,8 +0,0 @@
-package org.hibernate.test.annotations.genericsinheritance;
-
-import javax.persistence.Entity;
-
- at Entity
-public class ChildHierarchy22 extends ChildHierarchy2<ParentHierarchy22> {
-
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy22.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy22.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,24 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.genericsinheritance;
-
-import org.hibernate.test.annotations.TestCase;
-import org.hibernate.Session;
-
-/**
- * @author Emmanuel Bernard
- */
-public class GenericsInheritanceTest extends TestCase {
-	public void testMapping() throws Exception {
-		Session s = openSession();
-		s.close();
-		//mapping is tested
-	}
-	protected Class[] getMappings() {
-		return new Class[] {
-				ChildHierarchy1.class,
-				ParentHierarchy1.class,
-				ChildHierarchy22.class,
-				ParentHierarchy22.class
-		};
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Parent.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Parent.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Parent.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,35 +0,0 @@
-package org.hibernate.test.annotations.genericsinheritance;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.MapKey;
-import javax.persistence.MappedSuperclass;
-import javax.persistence.OneToMany;
-
- at MappedSuperclass
-public abstract class Parent<C extends Child> {
-
-	@Id @GeneratedValue Long id;
-	@MapKey @OneToMany(mappedBy="parent") Map<Long,C> children = new HashMap<Long,C>();
-
-	
-	public Long getId() {
-		return id;
-	}
-	public void setId(Long id) {
-		this.id = id;
-	}
-	
-	
-	public Map<Long,C> getChildren() {
-		return children;
-	}
-	public void setChildren(Map<Long,C> children) {
-		this.children = children;
-	}
-	
-	
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Parent.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/Parent.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy1.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy1.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy1.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,8 +0,0 @@
-package org.hibernate.test.annotations.genericsinheritance;
-
-import javax.persistence.Entity;
-
- at Entity
-public class ParentHierarchy1 extends Parent<ChildHierarchy1> {
-
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy1.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy1.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy2.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy2.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy2.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,8 +0,0 @@
-package org.hibernate.test.annotations.genericsinheritance;
-
-import javax.persistence.MappedSuperclass;
-
- at MappedSuperclass
-public class ParentHierarchy2<C extends ChildHierarchy2> extends Parent<C> {
-
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy2.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy2.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy22.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy22.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy22.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,8 +0,0 @@
-package org.hibernate.test.annotations.genericsinheritance;
-
-import javax.persistence.Entity;
-
- at Entity
-public class ParentHierarchy22 extends ParentHierarchy2<ChildHierarchy22> {
-
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy22.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy22.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/Ball.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/Ball.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/Ball.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -14,7 +14,7 @@
  *
  * @author Emmanuel Bernard
  */
- at TableGenerator(name = "EMP_GEN", table = "GENERATOR_TABLE", pkColumnName = "key",
+ at TableGenerator(name = "EMP_GEN", table = "GENERATOR_TABLE", pkColumnName = "pkey",
 		valueColumnName = "hi", pkColumnValue = "Ball", allocationSize = 10)
 @Entity
 public class Ball implements Serializable {

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/Dog.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/Dog.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/Dog.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -16,7 +16,7 @@
  */
 @Entity
 @Table(name = "tbl_dog")
- at TableGenerator(name = "DogGen", table = "GENERATOR_TABLE", pkColumnName = "key",
+ at TableGenerator(name = "DogGen", table = "GENERATOR_TABLE", pkColumnName = "pkey",
 		valueColumnName = "hi", pkColumnValue = "Dog", allocationSize = 10)
 public class Dog {
 	private Integer id;

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/IdTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/IdTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/id/IdTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -278,4 +278,11 @@
 		};
 	}
 
+	@Override
+	protected String[] getXmlFiles() {
+		return new String[] {
+				"org/hibernate/test/annotations/orm.xml"
+		};
+	}
+
 }

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/IdentifierCollectionTest.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/IdentifierCollectionTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/IdentifierCollectionTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,45 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.identifiercollection;
-
-import org.hibernate.test.annotations.TestCase;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-
-
-/**
- * @author Emmanuel Bernard
- */
-public class IdentifierCollectionTest extends TestCase {
-	public void testIdBag() throws Exception {
-		Passport passport = new Passport();
-		passport.setName( "Emmanuel Bernard" );
-		Stamp canada = new Stamp();
-		canada.setCountry( "Canada" );
-		passport.getStamps().add( canada );
-		passport.getVisaStamp().add( canada );
-		Stamp norway = new Stamp();
-		norway.setCountry( "Norway" );
-		passport.getStamps().add( norway );
-		passport.getStamps().add(canada);
-		Session s = openSession();
-		Transaction tx = s.beginTransaction();
-		s.persist( passport );
-		s.flush();
-		//s.clear();
-		passport = (Passport) s.get( Passport.class, passport.getId() );
-		int canadaCount = 0;
-		for ( Stamp stamp : passport.getStamps() ) {
-			if ( "Canada".equals( stamp.getCountry() ) ) canadaCount++;
-		}
-		assertEquals( 2, canadaCount );
-		assertEquals( 1, passport.getVisaStamp().size() );
-		tx.rollback();
-		s.close();
-	}
-	protected Class[] getMappings() {
-		return new Class[] {
-				Passport.class,
-				Stamp.class
-		};
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/IdentifierCollectionTest.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/IdentifierCollectionTest.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Passport.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Passport.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Passport.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,70 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.identifiercollection;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.TableGenerator;
-
-import org.hibernate.annotations.CollectionId;
-import org.hibernate.annotations.Type;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
- at TableGenerator(name="ids_generator", table="IDS")
-public class Passport {
-	@Id @GeneratedValue @Column(name="passport_id") private Long id;
-	private String name;
-
-	@ManyToMany(cascade = CascadeType.ALL)
-	@JoinTable(name="PASSPORT_STAMP")
-	@CollectionId(columns = @Column(name="COLLECTION_ID"), type=@Type(type="long"), generator = "generator")
-	@TableGenerator(name="generator", table="IDSTAMP")
-	private Collection<Stamp> stamps = new ArrayList();
-
-	@ManyToMany(cascade = CascadeType.ALL)
-	@JoinTable(name="PASSPORT_VISASTAMP")
-	@CollectionId(columns = @Column(name="COLLECTION_ID"), type=@Type(type="long"), generator = "ids_generator")
-	//TODO test identity generator
-	private Collection<Stamp> visaStamp = new ArrayList();
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public Collection<Stamp> getStamps() {
-		return stamps;
-	}
-
-	public void setStamps(Collection<Stamp> stamps) {
-		this.stamps = stamps;
-	}
-
-	public Collection<Stamp> getVisaStamp() {
-		return visaStamp;
-	}
-
-	public void setVisaStamp(Collection<Stamp> visaStamp) {
-		this.visaStamp = visaStamp;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Passport.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Passport.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Stamp.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Stamp.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Stamp.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,31 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.identifiercollection;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
-public class Stamp {
-	@Id @GeneratedValue private Long id;
-	private String country;
-
-	public String getCountry() {
-		return country;
-	}
-
-	public void setCountry(String country) {
-		this.country = country;
-	}
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Stamp.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/identifiercollection/Stamp.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Card.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Card.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Card.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,70 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.idmanytoone;
-
-import java.io.Serializable;
-import java.util.Set;
-import javax.persistence.Embeddable;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.CascadeType;
-import javax.persistence.FetchType;
-import javax.persistence.OneToMany;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
-public class Card {
-
-	@Id
-	private CardPrimaryKey primaryKey = new CardPrimaryKey();
-
-	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "primaryKey.card")
-	private Set<CardField> fields;
-
-	@ManyToOne
-	private CardField mainCardField;
-
-	@Embeddable
-	public static class CardPrimaryKey implements Serializable {
-
-		public CardPrimaryKey() {}
-
-		@ManyToOne(optional = false)
-		private Project project;
-
-		public Project getProject() {
-			return project;
-		}
-
-		public void setProject(Project project) {
-			this.project = project;
-		}
-
-	}
-
-	public Set<CardField> getFields() {
-		return fields;
-	}
-
-	public void setFields(Set<CardField> fields) {
-		this.fields = fields;
-	}
-
-	public CardPrimaryKey getPrimaryKey() {
-		return primaryKey;
-	}
-
-	public void setPrimaryKey(CardPrimaryKey primaryKey) {
-		this.primaryKey = primaryKey;
-	}
-
-	public CardField getMainCardField() {
-		return mainCardField;
-	}
-
-	public void setMainCardField(CardField mainCardField) {
-		this.mainCardField = mainCardField;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Card.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Card.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardField.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardField.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardField.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,64 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.idmanytoone;
-
-import java.io.Serializable;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.Embeddable;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
-public class CardField {
-
-	@Id
-	private PrimaryKey primaryKey = new PrimaryKey();
-
-	@ManyToOne
-	private Card cardtmp;
-
-	@Embeddable
-	public static class PrimaryKey implements Serializable {
-
-		@ManyToOne(optional = false)
-		private Card card;
-
-		@ManyToOne(optional = false)
-		private CardKey key;
-
-		public Card getCard() {
-			return card;
-		}
-
-		public void setCard(Card card) {
-			this.card = card;
-		}
-
-		public CardKey getKey() {
-			return key;
-		}
-
-		public void setKey(CardKey key) {
-			this.key = key;
-		}
-	}
-
-	public Card getCardtmp() {
-		return cardtmp;
-	}
-
-	public void setCardtmp(Card cardtmp) {
-		this.cardtmp = cardtmp;
-	}
-
-	public PrimaryKey getPrimaryKey() {
-		return primaryKey;
-	}
-
-	public void setPrimaryKey(PrimaryKey primaryKey) {
-		this.primaryKey = primaryKey;
-	}
-}
-

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardField.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardField.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardKey.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardKey.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardKey.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,24 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.idmanytoone;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
-public class CardKey {
-	@Id
-	@GeneratedValue
-	private int id;
-
-	public int getId() {
-		return id;
-	}
-
-	public void setId(int id) {
-		this.id = id;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardKey.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/CardKey.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/IdManyToOne.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/IdManyToOne.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/IdManyToOne.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,50 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.idmanytoone;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.test.annotations.TestCase;
-
-/**
- * @author Emmanuel Bernard
- */
-public class IdManyToOne extends TestCase {
-	public void testFkCreationOrdering() throws Exception {
-		//no real test case, the sessionFactory building is tested
-		Session s = openSession();
-		s.close();
-	}
-
-	public void getBiDirOneToManyInId() throws Exception {
-		Session s = openSession();
-		Transaction tx = s.beginTransaction();
-		CardKey key = new CardKey();
-		s.persist( key );
-		Project project = new Project();
-		s.persist( project );
-		Card card = new Card();
-		card.getPrimaryKey().setProject( project );
-		s.persist( card );
-		CardField field = new CardField();
-		field.getPrimaryKey().setKey( key );
-		field.getPrimaryKey().setCard( card );
-		s.persist( field );
-		card.setMainCardField( field );
-		s.flush();
-		s.clear();
-		card = (Card) s.createQuery( "from Card c").list().get(0);
-		assertEquals( 1, card.getFields().size() );
-		assertEquals( card.getMainCardField(), card.getFields().iterator().next() );
-		tx.rollback();
-		s.close();
-	}
-
-	protected Class[] getMappings() {
-		return new Class[] {
-				CardKey.class,
-				CardField.class,
-				Card.class,
-				Project.class
-		};
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/IdManyToOne.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/IdManyToOne.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Project.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Project.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Project.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,25 +0,0 @@
-//$Id: $
-package org.hibernate.test.annotations.idmanytoone;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
-
-/**
- * @author Emmanuel Bernard
- */
- at Entity
-public class Project {
-
-	@Id
-	@GeneratedValue
-	private int id;
-
-	public int getId() {
-		return id;
-	}
-
-	public void setId(int id) {
-		this.id = id;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Project.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/idmanytoone/Project.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Atmosphere.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Atmosphere.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Atmosphere.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -10,8 +10,11 @@
 import javax.persistence.ManyToMany;
 import javax.persistence.Column;
 import javax.persistence.JoinTable;
+import javax.persistence.JoinColumn;
 
 import org.hibernate.annotations.MapKey;
+import org.hibernate.annotations.CollectionOfElements;
+import org.hibernate.annotations.MapKeyManyToMany;
 
 /**
  * @author Emmanuel Bernard
@@ -27,6 +30,13 @@
 	public Map<String, Gas> gases = new HashMap<String, Gas>();
 
 	@ManyToMany(cascade = CascadeType.ALL)
+	@MapKeyManyToMany(joinColumns = @JoinColumn(name="gas_id") )
 	@JoinTable(name = "Gas_per_key")
 	public Map<GasKey, Gas> gasesPerKey = new HashMap<GasKey, Gas>();
+
+	@CollectionOfElements
+	@Column(name="composition_rate")
+	@MapKeyManyToMany(joinColumns = @JoinColumn(name="gas_id"))
+	@JoinTable(name = "Composition", joinColumns = @JoinColumn(name = "atmosphere_id"))
+	public Map<Gas, Double> composition = new HashMap<Gas, Double>();
 }

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -207,11 +207,11 @@
 		s = openSession();
 		tx = s.beginTransaction();
 		AlphabeticalDirectory m = new AlphabeticalDirectory();
-		m.setName("M");
+		m.setName( "M" );
 		AlphabeticalDirectory v = new AlphabeticalDirectory();
-		v.setName("V");
-		s.persist(m);
-		s.persist(v);
+		v.setName( "V" );
+		s.persist( m );
+		s.persist( v );
 
 		AddressBook book = new AddressBook();
 		book.setOwner( "Emmanuel" );
@@ -371,14 +371,18 @@
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		Atmosphere atm = new Atmosphere();
+		Atmosphere atm2 = new Atmosphere();
 		GasKey key = new GasKey();
 		key.setName( "O2" );
 		Gas o2 = new Gas();
 		o2.name = "oxygen";
 		atm.gases.put( "100%", o2 );
-		atm.gasesPerKey.put(key, o2);
+		atm.gasesPerKey.put( key, o2 );
+		atm2.gases.put( "100%", o2 );
+		atm2.gasesPerKey.put( key, o2 );
 		s.persist( key );
 		s.persist( atm );
+		s.persist( atm2 );
 		s.flush();
 		s.clear();
 
@@ -386,11 +390,52 @@
 		key = (GasKey) s.get( GasKey.class, key.getName() );
 		assertEquals( 1, atm.gases.size() );
 		assertEquals( o2.name, atm.gases.get( "100%" ).name );
-		assertEquals( o2.name, atm.gasesPerKey.get(key).name );
+		assertEquals( o2.name, atm.gasesPerKey.get( key ).name );
 		tx.rollback();
 		s.close();
 	}
 
+	public void testEntityKeyElementTarget() throws Exception {
+		Session s = openSession();
+		Transaction tx = s.beginTransaction();
+		Atmosphere atm = new Atmosphere();
+		Gas o2 = new Gas();
+		o2.name = "oxygen";
+		atm.composition.put( o2, 94.3 );
+		s.persist( o2 );
+		s.persist( atm );
+		s.flush();
+		s.clear();
+
+		atm = (Atmosphere) s.get( Atmosphere.class, atm.id );
+		assertEquals( 1, atm.composition.size() );
+		assertEquals( o2.name, atm.composition.keySet().iterator().next().name );
+		tx.rollback();
+		s.close();
+	}
+
+	public void testSortedMap() {
+		Session s = openSession();
+		Transaction tx = s.beginTransaction();
+		Training training = new Training();
+		Trainee trainee = new Trainee();
+		trainee.setName( "Jim" );
+		Trainee trainee2 = new Trainee();
+		trainee2.setName( "Emmanuel" );
+		s.persist( trainee );
+		s.persist( trainee2 );
+		training.getTrainees().put("Jim", trainee);
+		training.getTrainees().put("Emmanuel", trainee2);
+		s.persist( training );
+		s.flush();
+		s.clear();
+		training = (Training) s.get( Training.class, training.getId() );
+		assertEquals( "Emmanuel", training.getTrainees().firstKey() );
+		assertEquals( "Jim", training.getTrainees().lastKey() );
+		tx.rollback();
+		s.close();
+	}
+
 	public IndexedCollectionTest(String x) {
 		super( x );
 	}
@@ -413,7 +458,9 @@
 				Atmosphere.class,
 				Gas.class,
 				AlphabeticalDirectory.class,
-				GasKey.class
+				GasKey.class,
+				Trainee.class,
+				Training.class
 		};
 	}
 }

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Trainee.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Trainee.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Training.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Training.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.hbm.xml (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.hbm.xml)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/FinancialAsset.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/FinancialAsset.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -123,6 +123,37 @@
 		session.close();
 	}
 
+//	public void testManyToOneAndJoin() throws Exception {
+//		Session session = openSession();
+//		Transaction transaction = session.beginTransaction();
+//		Parent parent = new Parent();
+//		session.persist( parent );
+//		PropertyAsset property = new PropertyAsset();
+//		property.setParent( parent );
+//		property.setPrice( 230000d );
+//		FinancialAsset financial = new FinancialAsset();
+//		financial.setParent( parent );
+//		financial.setPrice( 230000d );
+//		session.persist( financial );
+//		session.persist( property );
+//		session.flush();
+//		session.clear();
+//		parent = (Parent) session.get( Parent.class, parent.getId() );
+//		assertNotNull( parent );
+//		assertEquals( 1, parent.getFinancialAssets().size() );
+//		assertEquals( 1, parent.getPropertyAssets().size() );
+//		assertEquals( property.getId(), parent.getPropertyAssets().iterator().next() );
+//		transaction.rollback();
+//		session.close();
+//	}
+
+	@Override
+	protected String[] getXmlFiles() {
+		return new String[] {
+				//"org/hibernate/test/annotations/inheritance/joined/Asset.hbm.xml"
+		};
+	}
+
 	/**
 	 * @see org.hibernate.test.annotations.TestCase#getMappings()
 	 */
@@ -136,7 +167,11 @@
 				Clothing.class,
 				Sweater.class,
 				EventInformation.class,
-				Alarm.class
+				Alarm.class,
+				//Asset.class,
+				//Parent.class,
+				//PropertyAsset.class,
+				//FinancialAsset.class
 		};
 	}
 

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Parent.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Parent.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Pool.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Pool.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/PropertyAsset.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/PropertyAsset.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/SwimmingPool.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/SwimmingPool.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/mixed/Document.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/mixed/Document.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/mixed/Document.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -5,6 +5,7 @@
 import javax.persistence.DiscriminatorValue;
 import javax.persistence.Entity;
 import javax.persistence.SecondaryTable;
+import javax.persistence.Table;
 
 /**
  * @author Emmanuel Bernard
@@ -12,6 +13,7 @@
 @Entity
 @DiscriminatorValue("D")
 @SecondaryTable(name = "DocumentMixed")
+ at Table(name="Document_Wrong") //illegal use, a warn is raised
 public class Document extends File {
 	private int size;
 

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/singletable/Building.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/singletable/Building.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/singletable/Building.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -8,11 +8,14 @@
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 
+import org.hibernate.annotations.ForceDiscriminator;
+
 /**
  * @author Emmanuel Bernard
  */
 @Entity
 @DiscriminatorColumn(name = "discriminator_disc")
+ at ForceDiscriminator
 @DiscriminatorValue("B")
 public class Building {
 	@Id

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/singletable/SingleTableTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/singletable/SingleTableTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/singletable/SingleTableTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,9 +2,11 @@
 package org.hibernate.test.annotations.inheritance.singletable;
 
 import java.util.List;
+import java.sql.Statement;
 
 import org.hibernate.Session;
 import org.hibernate.Transaction;
+import org.hibernate.WrongClassException;
 import org.hibernate.test.annotations.TestCase;
 import org.hibernate.test.annotations.inheritance.Apple;
 import org.hibernate.test.annotations.inheritance.Fruit;
@@ -27,6 +29,26 @@
 		s.close();
 	}
 
+	public void testForceDiscriminator() throws Exception {
+		Session s = openSession();
+		Transaction tx = s.beginTransaction();
+		Building b = new Building();
+		s.persist( b );
+		s.flush();
+		Statement statement = s.connection().createStatement();
+		statement.executeUpdate( "update Building set discriminator_disc = 'N'");
+		statement.close();
+		s.clear();
+		try {
+			assertEquals( 0, s.createQuery( "select b from Building b" ).list().size() );
+		}
+		catch (WrongClassException e) {
+			fail("the wrong discriminator is not filtered");
+		}
+		tx.rollback();
+		s.close();
+	}
+
 	public void testDefault() throws Exception {
 		Session s;
 		Transaction tx;

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Building.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Building.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/BuildingCompany.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/BuildingCompany.java)

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Company.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Company.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Group.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Group.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Group.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -8,14 +8,22 @@
 import javax.persistence.JoinColumn;
 import javax.persistence.JoinTable;
 import javax.persistence.ManyToMany;
+import javax.persistence.OrderBy;
 import javax.persistence.Table;
 import javax.persistence.UniqueConstraint;
 
+import org.hibernate.annotations.Where;
+import org.hibernate.annotations.FilterDef;
+import org.hibernate.annotations.Filter;
+import org.hibernate.annotations.FilterJoinTable;
+import org.hibernate.annotations.WhereJoinTable;
+
 /**
  * @author Emmanuel Bernard
  */
 @Entity
 @Table(name = "tbl_group")
+ at FilterDef(name="Groupfilter")
 public class Group {
 	private Integer id;
 	private Collection<Permission> permissions;
@@ -35,6 +43,11 @@
 			joinColumns = @JoinColumn(name = "group_id", referencedColumnName = "id"),
 			inverseJoinColumns = @JoinColumn(name = "permission", referencedColumnName = "permission")
 	)
+	@OrderBy("expirationDate")
+	@Where(clause = "1=1")
+	@WhereJoinTable(clause = "2=2")
+	@Filter(name="Groupfilter", condition = "3=3")
+	@FilterJoinTable(name="Groupfilter", condition = "4=4")
 	public Collection<Permission> getPermissions() {
 		return permissions;
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/ManyToManyTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/ManyToManyTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/ManyToManyTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -4,6 +4,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -77,6 +78,41 @@
 		s.close();
 	}
 
+	public void testUnmodifiableCollection() throws Exception {
+		Session s;
+		Transaction tx;
+		s = openSession();
+		tx = s.beginTransaction();
+		Cat cat = new Cat();
+		cat.setId( new CatPk() );
+		cat.getId().setName( "titi" );
+		cat.getId().setThoroughbred( "unknown" );
+		Set<Woman> women = new HashSet<Woman>();
+		Woman woman = new Woman();
+		woman.setId( new WomanPk() );
+		woman.getId().setFirstName( "Lady" );
+		woman.getId().setLastName( "McBeth" );
+		women.add( woman );
+		cat.setHumanContacts( Collections.unmodifiableSet( women ) );
+		Set<Cat> cats = new HashSet<Cat>();
+		cats.add( cat );
+		woman.setCats( Collections.unmodifiableSet(cats) );
+		s.persist( cat );
+		s.persist( woman );
+		tx.commit();
+		s.merge( woman );
+		s.close();
+
+		s = openSession();
+		tx = s.beginTransaction();
+		woman = (Woman) s.get(Woman.class, woman.getId() );
+		s.delete( woman.getCats().iterator().next() );
+		s.delete( woman );
+		tx.commit();
+		s.close();
+
+	}
+
 	public void testDefaultCompositePk() throws Exception {
 		Session s;
 		Transaction tx;
@@ -439,6 +475,32 @@
 		}
 	}
 
+	public void testAssociationTableAndOrderBy() throws Exception {
+		Session s = openSession();
+		s.enableFilter( "Groupfilter" );
+		Permission readAccess = new Permission();
+		readAccess.setPermission( "read" );
+		readAccess.setExpirationDate( new Date() );
+		Permission writeAccess = new Permission();
+		writeAccess.setPermission( "write" );
+		writeAccess.setExpirationDate( new Date( new Date().getTime() - 10*60*1000 ) );
+		Collection<Permission> coll = new ArrayList<Permission>( 2 );
+		coll.add( readAccess );
+		coll.add( writeAccess );
+		Group group = new Group();
+		group.setId( new Integer( 1 ) );
+		group.setPermissions( coll );
+		s.getTransaction().begin();
+		s.persist( group );
+		s.flush();
+		s.clear();
+		group = (Group) s.get( Group.class, group.getId() );
+		s.createQuery( "select g from Group g join fetch g.permissions").list();
+		assertEquals( "write", group.getPermissions().iterator().next().getPermission() );
+		s.getTransaction().rollback();
+		s.close();
+	}
+
 	public void testJoinedSubclassManyToMany() throws Exception {
 		Session s = openSession();
 		Zone a = new Zone();
@@ -484,6 +546,24 @@
 		s.close();
 	}
 
+	public void testReferencedColumnNameToSuperclass() throws Exception {
+		Session s = openSession();
+		Transaction tx = s.beginTransaction();
+		BuildingCompany comp = new BuildingCompany();
+		comp.setFoundedIn( new Date() );
+		comp.setName( "Builder century corp.");
+		s.persist( comp );
+		Building building = new Building();
+		building.setCompany( comp );
+		s.persist( building );
+		s.flush();
+		s.clear();
+		building = (Building) s.get( Building.class, building.getId() );
+		assertEquals( comp.getName(), building.getCompany().getName() );
+		tx.rollback();
+		s.close();
+	}
+
 	/**
 	 * @see org.hibernate.test.annotations.TestCase#getMappings()
 	 */
@@ -503,7 +583,9 @@
 				Permission.class,
 				Zone.class,
 				Inspector.class,
-				InspectorPrefixes.class
+				InspectorPrefixes.class,
+				BuildingCompany.class,
+				Building.class
 
 		};
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Woman.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Woman.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Woman.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -10,6 +10,8 @@
 import javax.persistence.JoinTable;
 import javax.persistence.ManyToMany;
 
+import org.hibernate.annotations.ForeignKey;
+
 /**
  * Woman knowing several mens
  *
@@ -44,6 +46,7 @@
 			@JoinColumn(name = "manFirstName", referencedColumnName = "firstName")
 					}
 	)
+	@ForeignKey(name = "WM_W_FK", inverseName = "WM_M_FK")
 	public Set<Man> getMens() {
 		return mens;
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Car.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Car.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Car.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -7,6 +7,8 @@
 import javax.persistence.Id;
 import javax.persistence.ManyToOne;
 
+import org.hibernate.annotations.ForeignKey;
+
 /**
  * Many to one sample using default mapping values
  *
@@ -29,6 +31,7 @@
 	}
 
 	@ManyToOne(fetch = FetchType.EAGER)
+	@ForeignKey(name="BODY_COLOR_FK")
 	public Color getBodyColor() {
 		return bodyColor;
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ForestType.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ForestType.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ForestType.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -10,6 +10,8 @@
 import javax.persistence.JoinTable;
 import javax.persistence.JoinColumn;
 
+import org.hibernate.annotations.ForeignKey;
+
 /**
  * @author Emmanuel Bernard
  */
@@ -25,6 +27,9 @@
 		joinColumns = @JoinColumn(name="forest_type"),
 		inverseJoinColumns = @JoinColumn(name="forest")
 	)
+	@ForeignKey(name="A_TYP_FK",
+			inverseName = "A_FOR_FK" //inverse fail cause it involves a Join
+	)
 	public BiggestForest getBiggestRepresentative() {
 		return biggestRepresentative;
 	}

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ManyToOneTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ManyToOneTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ManyToOneTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -173,6 +173,18 @@
 		assertNotNull( discount );
 		assertFalse( Hibernate.isInitialized( discount.getOwner() ) );
 		tx.commit();
+
+		s = openSession();
+		tx = s.beginTransaction();
+		discount = (Discount) s.load( Discount.class, discount.getId() );
+		assertNotNull( discount );
+		assertFalse( Hibernate.isInitialized( discount.getOwner() ) );
+		tx.commit();
+
+		s = openSession();
+		tx = s.beginTransaction();
+		s.delete( s.get( Discount.class, discount.getId() ) );
+		tx.commit();
 		s.close();
 	}
 

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/City.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/City.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/City.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -10,6 +10,8 @@
 import javax.persistence.OneToMany;
 import javax.persistence.OrderBy;
 
+import org.hibernate.annotations.ForeignKey;
+
 /**
  * @author Emmanuel Bernard
  */
@@ -39,7 +41,7 @@
 	}
 
 	@OneToMany(mappedBy = "city")
-	@OrderBy("streetName, id")
+	@OrderBy("streetNameCopy, streetName, id")
 	public synchronized List<Street> getStreets() {
 		return streets;
 	}
@@ -50,6 +52,7 @@
 
 	@OneToMany()
 	@JoinColumn(name = "mainstreetcity_id")
+	@ForeignKey(name = "CITYSTR_FK")
 	@OrderBy
 	public List<Street> getMainStreets() {
 		return mainStreets;

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/OneToManyTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/OneToManyTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/OneToManyTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -49,7 +49,7 @@
 		s.close();
 	}
 
-	public void testListWithBagSemantic() throws Exception {
+	public void testListWithBagSemanticAndOrderBy() throws Exception {
 		Session s;
 		Transaction tx;
 		s = openSession();
@@ -74,6 +74,7 @@
 		tx.commit();
 		s.clear();
 		tx = s.beginTransaction();
+		//testing @OrderBy with explicit values including Formula
 		paris = (City) s.get( City.class, paris.getId() );
 		assertEquals( 3, paris.getStreets().size() );
 		assertEquals( chmpsElysees.getStreetName(), paris.getStreets().get( 0 ).getStreetName() );

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/Street.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/Street.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/Street.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -5,7 +5,10 @@
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 import javax.persistence.ManyToOne;
+import javax.persistence.Column;
 
+import org.hibernate.annotations.Formula;
+
 /**
  * @author Emmanuel Bernard
  */
@@ -13,6 +16,7 @@
 public class Street {
 	private Integer id;
 	private String streetName;
+	private String streetNameCopy;
 	private City city;
 
 	@Id
@@ -25,6 +29,7 @@
 		this.id = id;
 	}
 
+	@Column(name="STREET_NAME")
 	public String getStreetName() {
 		return streetName;
 	}
@@ -33,6 +38,15 @@
 		this.streetName = streetName;
 	}
 
+	@Formula("STREET_NAME")
+	public String getStreetNameCopy() {
+		return streetNameCopy;
+	}
+
+	public void setStreetNameCopy(String streetNameCopy) {
+		this.streetNameCopy = streetNameCopy;
+	}
+
 	@ManyToOne
 	public City getCity() {
 		return city;

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/Trainer.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/Trainer.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetomany/Trainer.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -9,6 +9,8 @@
 import javax.persistence.JoinTable;
 import javax.persistence.OneToMany;
 
+import org.hibernate.annotations.ForeignKey;
+
 /**
  * Unidirectional one to many sample
  *
@@ -54,6 +56,7 @@
 			joinColumns = {@JoinColumn(name = "trainer_id")},
 			inverseJoinColumns = @JoinColumn(name = "monkey_id")
 	)
+	@ForeignKey(name = "TM_TRA_FK", inverseName = "TM_MON_FK")
 	public Set<Monkey> getTrainedMonkeys() {
 		return trainedMonkeys;
 	}

Added: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/Incident.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/Incident.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/Incident.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -0,0 +1,46 @@
+//$Id: $
+package org.hibernate.test.annotations.onetoone;
+
+import java.io.Serializable;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+/**
+ * @author Emmanuel Bernard
+ */
+ at Entity
+public class Incident implements Serializable  {
+	@Id
+	String id;
+
+	// See FK does *not* reference PK of IncidentStatus table
+	@ManyToOne(cascade = CascadeType.ALL)
+	@JoinColumn(referencedColumnName = "code")
+	IncidentStatus incidentStatus;
+
+	Incident() {
+	}
+
+	Incident(String id) {
+		this.id = id;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public IncidentStatus getIncidentStatus() {
+		return incidentStatus;
+	}
+
+	public void setIncidentStatus(IncidentStatus incidentStatus) {
+		this.incidentStatus = incidentStatus;
+	}
+}

Added: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/IncidentStatus.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/IncidentStatus.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/IncidentStatus.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -0,0 +1,56 @@
+//$Id: $
+package org.hibernate.test.annotations.onetoone;
+
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+
+/**
+ * @author Emmanuel Bernard
+ */
+
+ at Entity
+public class IncidentStatus implements Serializable {
+	@Id
+	String id;
+
+	@Column(nullable = false)
+	String code;
+
+	@OneToOne(mappedBy = "incidentStatus")
+	Incident incident;
+
+	public IncidentStatus() {
+	}
+
+	public IncidentStatus(String id) {
+		this.id = id;
+		this.code = "code_" + id;
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public Incident getIncident() {
+		return incident;
+	}
+
+	public void setIncident(Incident incident) {
+		this.incident = incident;
+	}
+}
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/OneToOneTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/OneToOneTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/onetoone/OneToOneTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -19,6 +19,40 @@
 		super( x );
 	}
 
+	public void testNonPkreference() throws Exception {
+		Session s;
+		Transaction tx;
+		s = openSession();
+		tx = s.beginTransaction();
+		Incident incident = new Incident( );
+		incident.id = "n23";
+
+		IncidentStatus status = new IncidentStatus( );
+		status.code = "RED";
+		status.id ="RED";
+
+		incident.incidentStatus = status;
+		status.incident = incident;
+		s.persist( incident );
+		s.flush();
+		s.clear();
+		incident = (Incident) s.get(Incident.class, incident.id);
+		assertNotNull( incident );
+		assertNotNull( incident.incidentStatus );
+		tx.rollback();
+		s.clear();
+		tx = s.beginTransaction();
+		String id="RED";
+		Incident i = (Incident) s.get(Incident.class, id);
+		i = new Incident(id);
+		IncidentStatus ist = new IncidentStatus(id);
+		i.setIncidentStatus(ist);
+		ist.setIncident(i);
+		s.persist(i);
+		tx.commit();
+		s.close();
+	}
+
 	public void testEagerFetching() throws Exception {
 		Session s;
 		Transaction tx;
@@ -261,7 +295,9 @@
 				Body.class,
 				Heart.class,
 				Owner.class,
-				OwnerAddress.class
+				OwnerAddress.class,
+				Incident.class,
+				IncidentStatus.class
 		};
 	}
 

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/orm.xml (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/orm.xml)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/override/Trip.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/override/Trip.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/override/Trip.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -11,8 +11,8 @@
  */
 @Entity
 @AssociationOverrides({
- at AssociationOverride(name = "from", joinColumns = @JoinColumn(name = "from", nullable = false)),
- at AssociationOverride(name = "to", joinColumns = @JoinColumn(name = "to", nullable = false))
+ at AssociationOverride(name = "from", joinColumns = @JoinColumn(name = "from2", nullable = false)),
+ at AssociationOverride(name = "to", joinColumns = @JoinColumn(name = "to2", nullable = false))
 		})
 public class Trip extends Move {
 }

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/package-info.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/package-info.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/package-info.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,21 +0,0 @@
-/**
- * Test package for metatata facilities
- * It contains an example of package level metadata
- */
-
- at TableGenerator(
-		name = "EMP_GEN",
-		table = "GENERATOR_TABLE",
-		pkColumnName = "key",
-		valueColumnName = "hi",
-		pkColumnValue = "EMP",
-		allocationSize = 20
-)
- at SequenceGenerator(
-		name = "SEQ_GEN",
-		sequenceName = "my_sequence"
-) package org.hibernate.test.annotations;
-
-import javax.persistence.SequenceGenerator;
-import javax.persistence.TableGenerator;
-

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/Dimensions.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/Dimensions.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/Dimensions.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -8,6 +8,8 @@
  */
 @Embeddable
 public class Dimensions {
+	
+
 	private int length;
 	private int width;
 

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -303,4 +303,11 @@
 				"org.hibernate.test.annotations.query"
 		};
 	}
+
+	@Override
+	protected String[] getXmlFiles() {
+		return new String[] {
+				"org/hibernate/test/annotations/query/orm.xml"
+		};
+	}
 }

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/orm.xml (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/orm.xml)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/package-info.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/package-info.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/package-info.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,34 +0,0 @@
-/**
- * Test package for metatata facilities
- * It contains an example of named queries
- */
-
- at javax.persistence.NamedQuery(name = "plane.getAll", query = "select p from Plane p")
- at NamedNativeQueries({
- at javax.persistence.NamedNativeQuery(
-		name = "night.getAll.bySQL",
-		query = "select id, night_duration, night_date as dte, area_id from Night where night_duration > ?",
-		resultSetMapping = "sqlmapping")
-		}
-)
- at NamedNativeQuery(name = "getAreaByNative", query = "select * from tbl_area", resultClass = Area.class)
- at SqlResultSetMapping(
-		name = "sqlmapping",
-		entities = {
-		@EntityResult(
-				entityClass = org.hibernate.test.annotations.query.Night.class,
-				fields = {
-				@FieldResult(name = "id", column = "id"),
-				@FieldResult(name = "duration", column = "night_duration"),
-				@FieldResult(name = "date", column = "dte"),
-				@FieldResult(name = "area", column = "area_id")
-						}
-		)
-				}
-) package org.hibernate.test.annotations.query;
-
-import javax.persistence.EntityResult;
-import javax.persistence.FieldResult;
-import javax.persistence.NamedNativeQueries;
-import javax.persistence.NamedNativeQuery;
-import javax.persistence.SqlResultSetMapping;

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/JavaXClassTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/JavaXClassTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/JavaXClassTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -41,6 +41,11 @@
 		assertEquals( grandpa, fatherAsSeenFromSon.getSuperclass() );
 	}
 
+	public void testSuperSuperClass() {
+		assertEquals( factory.toXClass( Object.class ), grandpa.getSuperclass() );
+		assertEquals( null, grandpa.getSuperclass().getSuperclass() );
+	}
+
 	public void testHasInterfaces() {
 		XClass[] interfaces = fatherAsSeenFromSon.getSuperclass().getInterfaces();
 		assertEquals( 2, interfaces.length );

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DeepGenericsInheritance.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DeepGenericsInheritance.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DeepGenericsInheritance.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,23 +0,0 @@
-//$Id: $
-package org.hibernate.test.reflection.java.generics.deep;
-
-import junit.framework.TestCase;
-import org.hibernate.reflection.java.JavaXFactory;
-import org.hibernate.reflection.XClass;
-
-
-/**
- * @author Emmanuel Bernard
- */
-public class DeepGenericsInheritance extends TestCase {
-	public void test2StepsGenerics() throws Exception {
-		JavaXFactory factory = new JavaXFactory();
-		XClass subclass2 = factory.toXClass( Subclass2.class );
-		XClass dummySubclass = factory.toXClass( DummySubclass.class );
-		XClass superclass = subclass2.getSuperclass();
-		XClass supersuperclass = superclass.getSuperclass();
-		assertTrue( supersuperclass.getDeclaredProperties( "field" ).get( 1 ).isTypeResolved() );
-		assertEquals( dummySubclass, supersuperclass.getDeclaredProperties( "field" ).get( 1 ).getType() );
-
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DeepGenericsInheritance.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DeepGenericsInheritance.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Dummy.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Dummy.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Dummy.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,28 +0,0 @@
-package org.hibernate.test.reflection.java.generics.deep;
-
-import javax.persistence.MappedSuperclass;
-import javax.persistence.Id;
-
-/**
- *
- */
- at MappedSuperclass
-public class Dummy {
-    @Id
-    protected Long id;
-
-    private String name;
-
-
-    public Long getId() {
-        return id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Dummy.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Dummy.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DummySubclass.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DummySubclass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DummySubclass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,12 +0,0 @@
-package org.hibernate.test.reflection.java.generics.deep;
-
-import javax.persistence.Entity;
-
-import org.hibernate.test.reflection.java.generics.deep.Dummy;
-
-/**
- *
- */
- at Entity
-public class DummySubclass extends Dummy {
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DummySubclass.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DummySubclass.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass1.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass1.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass1.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,28 +0,0 @@
-package org.hibernate.test.reflection.java.generics.deep;
-
-import javax.persistence.MappedSuperclass;
-import javax.persistence.OneToOne;
-import javax.persistence.Id;
-
-import org.hibernate.test.reflection.java.generics.deep.Dummy;
-
-/**
- *
- */
- at MappedSuperclass
-public class GenericSuperclass1<T extends Dummy> {
-	@Id
-	protected Long id;
-
-	@OneToOne
-	protected T dummy;
-
-
-	public Long getId() {
-		return id;
-	}
-
-	public T getDummy() {
-		return dummy;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass1.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass1.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass2.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass2.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass2.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,13 +0,0 @@
-package org.hibernate.test.reflection.java.generics.deep;
-
-import javax.persistence.MappedSuperclass;
-
-import org.hibernate.test.reflection.java.generics.deep.Dummy;
-import org.hibernate.test.reflection.java.generics.deep.GenericSuperclass1;
-
-/**
- *
- */
- at MappedSuperclass
-public class GenericSuperclass2<T extends Dummy> extends GenericSuperclass1<T> {
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass2.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/GenericSuperclass2.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass1.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass1.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass1.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,13 +0,0 @@
-package org.hibernate.test.reflection.java.generics.deep;
-
-import javax.persistence.Entity;
-
-import org.hibernate.test.reflection.java.generics.deep.DummySubclass;
-import org.hibernate.test.reflection.java.generics.deep.GenericSuperclass1;
-
-/**
- *
- */
- at Entity
-public class Subclass1 extends GenericSuperclass1<DummySubclass> {
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass1.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass1.java)

Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass2.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass2.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass2.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,13 +0,0 @@
-package org.hibernate.test.reflection.java.generics.deep;
-
-import javax.persistence.Entity;
-
-import org.hibernate.test.reflection.java.generics.deep.DummySubclass;
-import org.hibernate.test.reflection.java.generics.deep.GenericSuperclass2;
-
-/**
- *
- */
- at Entity
-public class Subclass2 extends GenericSuperclass2<DummySubclass> {
-}

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass2.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/Subclass2.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/Administration.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/Administration.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/Administration.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -17,7 +17,7 @@
 @Entity(name = "JavaAdministration")
 @Table(name = "JavaAdministration")
 @SecondaryTable(name = "Extend")
-public class Administration {
+public class Administration extends Organization {
 	@Id
 	private Integer id;
 	private String firstname;

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/EJB3OverridenAnnotationReaderTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/EJB3OverridenAnnotationReaderTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/EJB3OverridenAnnotationReaderTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -73,6 +73,12 @@
  * @author Emmanuel Bernard
  */
 public class EJB3OverridenAnnotationReaderTest extends TestCase {
+	public void testMappedSuperclassAnnotations() throws Exception {
+		XMLContext context = buildContext( "org/hibernate/test/reflection/java/xml/metadata-complete.xml" );
+		EJB3OverridenAnnotationReader reader = new EJB3OverridenAnnotationReader( Organization.class, context );
+		assertTrue( reader.isAnnotationPresent( MappedSuperclass.class ) );
+	}
+
 	public void testEntityRelatedAnnotations() throws Exception {
 		XMLContext context = buildContext( "org/hibernate/test/reflection/java/xml/orm.xml" );
 		EJB3OverridenAnnotationReader reader = new EJB3OverridenAnnotationReader( Administration.class, context );

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/Organization.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/Organization.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/metadata-complete.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/metadata-complete.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/xml/metadata-complete.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -14,6 +14,11 @@
         </persistence-unit-defaults>
     </persistence-unit-metadata>
     <package>org.hibernate.test.reflection.java.xml</package>
+    <mapped-superclass class="Organization">
+        <attributes>
+            <basic name="organizationId"/>
+        </attributes>
+    </mapped-superclass>
     <entity class="Administration">
         <attributes>
             <id name="id"/>

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/HibernateAnnotationIntegrationTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/HibernateAnnotationIntegrationTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/HibernateAnnotationIntegrationTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -10,6 +10,7 @@
 import org.hibernate.mapping.PersistentClass;
 import org.hibernate.test.annotations.TestCase;
 import org.hibernate.validator.InvalidStateException;
+import org.hibernate.validator.Environment;
 import org.hibernate.validator.event.ValidatePreInsertEventListener;
 import org.hibernate.validator.event.ValidatePreUpdateEventListener;
 
@@ -68,6 +69,9 @@
 		catch (InvalidStateException e) {
 			//success
 			assertEquals( 2, e.getInvalidValues().length );
+			assertTrue( "Environment.MESSAGE_INTERPOLATOR_CLASS does not work",
+					e.getInvalidValues()[0].getMessage().startsWith( "prefix_")
+			);
 		}
 		finally {
 			if ( tx != null ) tx.rollback();
@@ -145,6 +149,7 @@
 	}
 
 	protected void configure(Configuration cfg) {
+		cfg.setProperty( Environment.MESSAGE_INTERPOLATOR_CLASS, PrefixMessageInterpolator.class.getName() );
 		cfg.getEventListeners()
 				.setPreInsertEventListeners( new PreInsertEventListener[]{new ValidatePreInsertEventListener()} );
 		cfg.getEventListeners()

Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/PrefixMessageInterpolator.java (from rev 10565, trunk/HibernateExt/metadata/src/test/org/hibernate/validator/test/PrefixMessageInterpolator.java)

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/Tv.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/Tv.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/Tv.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,11 +2,13 @@
 package org.hibernate.validator.test;
 
 import java.util.Date;
+import java.math.BigInteger;
 import javax.persistence.Entity;
 import javax.persistence.Id;
 
 import org.hibernate.validator.Future;
 import org.hibernate.validator.Length;
+import org.hibernate.validator.Min;
 
 /**
  * @author Emmanuel Bernard
@@ -23,4 +25,6 @@
 	public Date expDate;
 	@Length(min = 0)
 	public String description;
+	@Min(1000)
+	public BigInteger lifetime;
 }

Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/ValidatorTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/ValidatorTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/validator/test/ValidatorTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -4,10 +4,14 @@
 import java.util.Date;
 import java.util.Locale;
 import java.util.ResourceBundle;
+import java.math.BigInteger;
+import java.io.Serializable;
 
 import junit.framework.TestCase;
 import org.hibernate.validator.ClassValidator;
 import org.hibernate.validator.InvalidValue;
+import org.hibernate.validator.MessageInterpolator;
+import org.hibernate.validator.Validator;
 
 /**
  * @author Gavin King
@@ -110,7 +114,9 @@
 			assertEquals( "length must be between 0 and 2", invalidValues[0].getMessage() );
 		}
 		else if ( loc.toString().startsWith( "fr" ) ) {
-			assertEquals( "la longueur doit être entre 0 et 2", invalidValues[0].getMessage() );
+			String message = invalidValues[0].getMessage();
+			String message2 ="la longueur doit être entre 0 et 2"; 
+			assertEquals( message2, message );
 		}
 		else if ( loc.toString().startsWith( "da" ) ) {
 			assertEquals( "længden skal være mellem 0 og 2", invalidValues[0].getMessage() );
@@ -119,9 +125,53 @@
 			// if default not found then it must be english
 			assertEquals( "length must be between 0 and 2", invalidValues[0].getMessage() );
 		}
+	}
 
+	public class PrefixMessageInterpolator implements MessageInterpolator, Serializable {
+		private String prefix;
+
+		public PrefixMessageInterpolator(String prefix) {
+			this.prefix = prefix;
+		}
+
+		public String interpolate(String message, Validator validator, MessageInterpolator defaultInterpolator) {
+			return prefix + defaultInterpolator.interpolate( message, validator, defaultInterpolator );
+		}
 	}
 
+	public void testMessageInterpolator() throws Exception {
+		Tv tv = new Tv();
+		tv.serial = "FS";
+		tv.name = "TooLong";
+		tv.expDate = new Date( new Date().getTime() + 1000 * 60 * 60 * 24 * 10 );
+		String prefix = "Prefix";
+		ClassValidator<Tv> classValidator = new ClassValidator<Tv>( Tv.class, new PrefixMessageInterpolator( prefix )  );
+		InvalidValue[] invalidValues = classValidator.getInvalidValues( tv );
+		assertEquals( 1, invalidValues.length );
+		Locale loc = Locale.getDefault();
+		if ( loc.toString().startsWith( "en" ) ) {
+			assertEquals( prefix + "length must be between 0 and 2", invalidValues[0].getMessage() );
+		}
+		else if ( loc.toString().startsWith( "fr" ) ) {
+			assertEquals( prefix + "la longueur doit être entre 0 et 2", invalidValues[0].getMessage() );
+		}
+		else if ( loc.toString().startsWith( "da" ) ) {
+			assertEquals( prefix + "længden skal være mellem 0 og 2", invalidValues[0].getMessage() );
+		}
+		else {
+			// if default not found then it must be english
+			assertEquals( prefix + "length must be between 0 and 2", invalidValues[0].getMessage() );
+		}
+	}
+
+	public void testBigInteger() throws Exception {
+		Tv tv = new Tv();
+		tv.lifetime = new BigInteger("9223372036854775808");
+		ClassValidator<Tv> classValidator = new ClassValidator<Tv>( Tv.class );
+		InvalidValue[] invalidValues = classValidator.getInvalidValues( tv );
+		assertEquals( 0, invalidValues.length );
+	}
+
 	public void testBeanValidator() throws Exception {
 		Vase v = new Vase();
 		ClassValidator<Vase> classValidator = new ClassValidator<Vase>( Vase.class );

Modified: branches/Lucene_Integration/HibernateExt/tools/build.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/build.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/build.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -7,7 +7,7 @@
     <!-- Name of project and version, used to create filenames -->
     <property name="Name" value="Hibernate Tools"/>
     <property name="name" value="hibernate-tools"/>
-    <property name="version" value="3.2.0beta6"/>
+    <property name="version" value="3.2.0beta8"/>
 
 	<property name="javadoc.packagenames" value="org.hibernate.tool"/>	
 

Modified: branches/Lucene_Integration/HibernateExt/tools/changelog.txt
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/changelog.txt	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/changelog.txt	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,6 +1,12 @@
 Hibernate Tools Changelog
 =========================
 
+Changes in version 3.2alpha7
+----------------------------
+
+Changes in version 3.1alpha6
+----------------------------
+
 Changes in version 3.1alpha5
 ----------------------------
 

Modified: branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/master.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/master.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/master.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -14,7 +14,7 @@
 
     <subtitle>Reference Guide</subtitle>
 
-    <releaseinfo>3.2.0.beta6</releaseinfo>
+    <releaseinfo>3.2.0.beta8</releaseinfo>
 
     <mediaobject>
       <imageobject>

Modified: branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/ant.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/ant.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/ant.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -13,10 +13,20 @@
     This jar is 100% independent from the eclipse platform and can thus be
     used independently of eclipse.</para>
 
+    <para>
+    Note: until Hibernate 3.2 and related libraries are finally
+    released there might be incompabilities with respect to the tools.
+    Thus to avoid any confusion it is recommended to use the
+    hibernate3.jar &amp; hibernate-annotations.jar bundled with the
+    tools when you want to use the Ant tasks. Do not worry about using
+    e.g. Hibernate 3.2 jar's with e.g. an Hibernate 3.1 project since
+    the output generated will work with previous Hibernate 3 versions.
+    </para>   
+
     <section>
       <title>The <literal>&lt;hibernatetool&gt;</literal> ant Task</title>
 
-      <para>To use the ant tasks you ned to have the hibernatetool task
+      <para>To use the ant tasks you need to have the hibernatetool task
       defined. That is done in your build.xml by inserting the following xml
       (assuming the jars are in the <literal>lib</literal> directory):
       <programlisting><![CDATA[<path id="toolslib">
@@ -31,7 +41,7 @@
          classpathref="toolslib" />
 ]]></programlisting></para>
 
-      <para>his <literal>&lt;taskdef&gt;</literal> defines a Ant task called
+      <para>this <literal>&lt;taskdef&gt;</literal> defines a Ant task called
       <literal>&lt;hibernatetool&gt;</literal> which now can be used anywhere
       in your ant build.xml files. It is important to include all the
       hibernate tools dependencies as well as the jdbc driver.</para>
@@ -64,10 +74,10 @@
   templatepath="defaultTemplatePath"
 >
   <classpath ...>
-  <property name="propertyName" value="value"/>
+  <property key="propertyName" value="value"/>
   <propertyset ...>
   (<configuration ...>|<annotationconfiguration ...>|
-   <ejb3configuration ...>|<jdbcconfiguration ...>)
+   <jpaconfiguration ...>|<jdbcconfiguration ...>)
   (<hbm2java>,<hbm2cfgxml>,<hbmtemplate>,...*)  
 </hibernatetool>]]></programlisting>
 
@@ -152,9 +162,9 @@
       <para><literal>hibernatetool</literal> supports four different Hibernate
       configurations: A standard Hibernate configuration
       (<literal>&lt;configuration&gt;</literal>), Annotation based
-      configuration (<literal>&lt;annotationconfiguration&gt;</literal>), EJB3
+      configuration (<literal>&lt;annotationconfiguration&gt;</literal>), JPA
       persistence based configuration
-      (<literal>&lt;ejb3configuration&gt;</literal>) and a JDBC based
+      (<literal>&lt;jpaconfiguration&gt;</literal>) and a JDBC based
       configuration (<literal>&lt;jdbcconfiguration&gt;</literal>) for use
       when reverse engineering.</para>
 
@@ -287,29 +297,31 @@
       </section>
 
       <section>
-        <title>EJB3 based configuration (&lt;ejb3configuration&gt;)</title>
+        <title>JPA based configuration (&lt;jpaconfiguration&gt;)</title>
 
-        <para>An &lt;ejb3configuration&gt; is used when you want to read the
-        metamodel from EJB3/Hibernate Annotation where you want to use the
-        auto-scan configuration as defined in the EJB3 spec. In other words,
-        when you do not have a <literal>hibernate.cfg.xml</literal>, but
+        <para>An &lt;jpaconfiguration&gt; is used when you want to read the
+        metamodel from JPA/Hibernate Annotation where you want to use the
+        auto-scan configuration as defined in the JPA spec (part of EJB3). 
+        In other words, when you do not have a <literal>hibernate.cfg.xml</literal>, but
         instead have a setup where you use a
-        <literal>persistence.xml</literal> packaged in an EJB3 compliant
+        <literal>persistence.xml</literal> packaged in an JPA compliant
         manner.</para>
 
-        <para>Note, in the current version there is no additional attribute
-        support on &lt;ejb3configuration&gt; like found on
-        &lt;annotationconfiguration&gt; and &lt;configuration&gt;. It will
+        <para><literal>&lt;jpaconfiguration&gt;</literal> will
         simply just try and auto-configure it self based on the available
         classpath, e.g. look for META-INF/persistence.xml.</para>
+        
+        <para>The <literal>persistenceunit</literal> attribute can be used to select a specific
+        persistence unit. If no persistenceunit is specified it will automatically search for one and
+        if a unique one is found use it, but if multiple persistence units are available it will error.</para>
 
-        <para>To use an &lt;ejb3configuration&gt; you will need to specify
+        <para>To use an &lt;jpaconfiguration&gt; you will need to specify
         some additional jars from Hibernate EntityManager in the
         &lt;taskdef&gt; of the hibernatetool. The following shows a full
         setup:</para>
 
         <programlisting><![CDATA[<path id="ejb3toolslib">
- <path refid="toolslib"/> <!-- ref to previously defined toolslib -->
+ <path refid="jpatoolslib"/> <!-- ref to previously defined toolslib -->
  <path location="lib/hibernate-annotations.jar" />
  <path location="lib/ejb3-persistence.jar" />
  <path location="lib/hibernate-entitymanager.jar" />
@@ -319,20 +331,24 @@
    
 <taskdef name="hibernatetool" 
          classname="org.hibernate.tool.ant.HibernateToolTask" 
-         classpathref="ejb3toolslib" />
+         classpathref="jpatoolslib" />
 
 <hibernatetool destdir="${build.dir}">
- <ejb3configuration />
+ <jpaconfiguration persistenceunit="caveatemptor"/>
  <classpath>
   <!-- it is in this classpath you put your classes dir,
-   and/or ejb3 persistence compliant jar -->
-  <path location="${build.dir}/ejb3/classes" />
+   and/or jpa persistence compliant jar -->
+  <path location="${build.dir}/jpa/classes" />
  </classpath>
 
  <!-- list exporters here -->
 
 </hibernatetool>
 ]]></programlisting>
+
+<para>Note: <literal>ejb3configuration</literal> were the name used in previous versions. It still 
+works but will emit a warning telling you to use <literal>jpaconfiguration</literal> instead.</para>
+
       </section>
 
       <section>
@@ -357,6 +373,8 @@
               <area coords="4 57" id="xcfg2" />
 
               <area coords="5 57" id="xcfg3" />
+              <area coords="6 57" id="xcfg4" />
+              <area coords="7 57" id="xcfg5" />
             </areaspec>
 
             <programlisting><![CDATA[<jdbcconfiguration
@@ -364,19 +382,21 @@
   packagename="package.name"
   revengfile="hibernate.reveng.xml"
   reversestrategy="ReverseEngineeringStrategy classname"
+  detectmanytomany="true|false"
+  detectoptmisticlock="true|false"
 >
   ...
 </jdbcconfiguration>]]></programlisting>
 
             <calloutlist>
               <callout arearefs="xcfg1">
-                <para>packagename (optional): The default package name to use
+                <para><literal>packagename</literal> (optional): The default package name to use
                 when mappings for classes is created</para>
               </callout>
 
               <callout arearefs="xcfg2">
                 <para><literal>revengfile</literal> (optional): name of
-                reveng.xml that allows you to control varios aspects of the
+                reveng.xml that allows you to control various aspects of the
                 reverse engineering.</para>
               </callout>
 
@@ -390,6 +410,13 @@
                 addition to) a reveng.xml file gives you full programmatic
                 control of the reverse engineering.</para>
               </callout>
+
+              <callout arearefs="xcfg4">
+                <para>detectManytoMany (default:true): If true (the default) tables which are pure many-to-many link tables will be mapped as such. A pure many-to-many table is one which primary-key contains has exactly two foreign-keys pointing to other entity tables and has no other columns.</para>
+              </callout>
+              <callout arearefs="xcfg5">
+                <para>detectOptimisticLock (efault:true): If true columns named VERSION or TIMESTAMP with appropriate types will be mapped with the apropriate optimistic locking corresponding to <literal>&lt;version&gt;</literal> or <literal>&lt;timestamp&gt;</literal></para>
+              </callout>
             </calloutlist>
           </programlistingco></para>
 
@@ -595,7 +622,7 @@
           necessary.</para>
 
           <para><programlisting><![CDATA[<hibernatetool destdir="${build.dir}/generated">
- <annotaitonconfiguration configurationfile="hibernate.cfg.xml"/>
+ <annotationconfiguration configurationfile="hibernate.cfg.xml"/>
  <hbm2hbmxml/>
 </hibernatetool>]]></programlisting></para>
         </section>
@@ -688,8 +715,7 @@
       </section>
 
       <section id="hbmtemplate">
-        <title>Generic Hibernate metamodel exporter
-        (<literal>&lt;hbmtemplate&gt;</literal>)</title>
+        <title>Generic Hibernate metamodel exporter (<literal>&lt;hbmtemplate&gt;</literal>)</title>
 
         <para>Generic exporter that can be controlled by a user provided
         template or class.</para>
@@ -800,4 +826,4 @@
       </section>
     </section>
   </section>
-</chapter>
\ No newline at end of file
+</chapter>

Modified: branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/codegenarchitecture.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/codegenarchitecture.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/codegenarchitecture.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -25,12 +25,12 @@
 
     <para><mediaobject>
         <imageobject role="fo">
-          <imagedata fileref="images/architecture.png" format="png" />
+          <imagedata fileref="images/architecture.png" format="PNG" />
         </imageobject>
 
         <imageobject role="html">
           <imagedata align="center"
-                     fileref="../shared/images/architecture.png" format="png" />
+                     fileref="../shared/images/architecture.png" format="PNG" />
         </imageobject>
       </mediaobject></para>
 
@@ -54,7 +54,7 @@
 
     <para>Users can provide their own customer Exporter's, either by custom
     classes implementing the Exporter interface or simply be providing custom
-    templates. This is documented at <xref linkend="hbmtemplate" /></para>
+    templates. This is documented at <xref linkend="hbmtemplate"/></para>
 
         <para>NOTICE: This release uses Velocity for the templates. The next
         release might move to an alternative template engine.</para>

Modified: branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/plugins.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/plugins.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/plugins.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -52,13 +52,13 @@
 
     <mediaobject>
       <imageobject role="fo">
-        <imagedata fileref="images/hibernatecfgwizard.gif" format="gif" contentwidth="5cm" />
+        <imagedata fileref="images/hibernatecfgwizard.gif" format="GIF" contentwidth="5cm" />
       </imageobject>
 
       <imageobject role="html">
         <imagedata align="center"
                    fileref="../shared/images/hibernatecfgwizard.gif"
-                   format="gif" />
+                   format="GIF" />
       </imageobject>
     </mediaobject>
 
@@ -79,11 +79,9 @@
   </section>
 
   <section>
-     
-
     <title>Creating a Hibernate Console configuration</title>
 
-     A Console Configuration describes to the Hibernate plugin which configuration files should be used to configure hibernate, including which classpath is needed to load the POJO's, JDBC drivers etc. It is required to make usage of query prototyping, reverse engineering and code generation. You can have multiple named console configurations. Normally you would just need one per project, but more (or less) is definitly possible. 
+    <para>A Console Configuration describes to the Hibernate plugin which configuration files should be used to configure hibernate, including which classpath is needed to load the POJO's, JDBC drivers etc. It is required to make usage of query prototyping, reverse engineering and code generation. You can have multiple named console configurations. Normally you would just need one per project, but more (or less) is definitly possible. </para>
 
     <para>You create a console configuration by running the Console
     Configuration wizard, shown in the following screenshot. The same wizard
@@ -93,8 +91,7 @@
      
 
     <mediaobject>
-      <title>Creating a Hibernate Console configuration</title>
-
+      
       <imageobject role="fo">
         <imagedata fileref="images/consolecfgwizard.gif" format="GIF" />
       </imageobject>
@@ -102,8 +99,9 @@
       <imageobject role="html">
         <imagedata align="center"
                    fileref="../shared/images/consolecfgwizard.gif"
-                   format="gif" />
+                   format="GIF" />
       </imageobject>
+      <caption>Creating a Hibernate Console configuration</caption>      
     </mediaobject>
 
      
@@ -266,8 +264,7 @@
 
      
 
-    <mediaobject>
-      <title>Console overview</title>
+    <mediaobject>     
 
       <imageobject role="fo">
         <imagedata align="center" 
@@ -278,8 +275,10 @@
       <imageobject role="html">
         <imagedata align="center"
                    fileref="../shared/images/consoleoutline-before-reveng.gif"
-                   format="gif" />
+                   format="GIF" />
       </imageobject>
+      
+       <caption>Console overview</caption>
     </mediaobject>
 
      
@@ -315,7 +314,7 @@
         <imageobject role="html">
           <imagedata align="center"
                      fileref="../shared/images/codegendropdown.gif"
-                     format="gif" />
+                     format="GIF" />
         </imageobject>
       </mediaobject>
 
@@ -332,7 +331,7 @@
         <imageobject role="html">
           <imagedata align="center"
                      fileref="../shared/images/codegenmaintab.gif"
-                     format="gif" />
+                     format="GIF" />
         </imageobject>
       </mediaobject>
 
@@ -472,7 +471,7 @@
         <imageobject role="html">
           <imagedata align="center"
                      fileref="../shared/images/codegenexporters.gif"
-                     format="gif" />
+                     format="GIF" />
         </imageobject>
       </mediaobject>
 
@@ -582,7 +581,7 @@
       <imageobject role="html">
         <imagedata align="center"
                    fileref="../shared/images/hbmxmlcompletion.gif"
-                   format="gif" />
+                   format="GIF" />
       </imageobject>
     </mediaobject>
 
@@ -669,13 +668,13 @@
       <para><mediaobject>
           <imageobject role="fo">
             <imagedata fileref="images/cfgxml-propertycomplete.png"
-                       format="png" />
+                       format="PNG" />
           </imageobject>
 
           <imageobject role="html">
             <imagedata align="center"
                        fileref="../shared/images/cfgxml-propertycomplete.png"
-                       format="png" />
+                       format="PNG" />
           </imageobject>
         </mediaobject></para>
     </section>
@@ -709,13 +708,13 @@
 
     <para><mediaobject>
         <imageobject role="fo">
-          <imagedata fileref="images/revengxml_overview.png" format="png" />
+          <imagedata fileref="images/revengxml_overview.png" format="PNG" />
         </imageobject>
 
         <imageobject role="html">
           <imagedata align="center"
                      fileref="../shared/images/revengxml_overview.png"
-                     format="png" />
+                     format="PNG" />
         </imageobject>
       </mediaobject></para>
 
@@ -725,13 +724,13 @@
 
     <para><mediaobject>
         <imageobject role="fo">
-          <imagedata fileref="images/revengxml_tablefilters.png" format="png" />
+          <imagedata fileref="images/revengxml_tablefilters.png" format="PNG" />
         </imageobject>
 
         <imageobject role="html">
           <imagedata align="center"
                      fileref="../shared/images/revengxml_tablefilters.png"
-                     format="png" />
+                     format="PNG" />
         </imageobject>
       </mediaobject></para>
 
@@ -741,13 +740,13 @@
 
     <para><mediaobject>
         <imageobject role="fo">
-          <imagedata fileref="images/revengxml_typemappings.png" format="png" />
+          <imagedata fileref="images/revengxml_typemappings.png" format="PNG" />
         </imageobject>
 
         <imageobject role="html">
           <imagedata align="center"
                      fileref="../shared/images/revengxml_typemappings.png"
-                     format="png" />
+                     format="PNG" />
         </imageobject>
       </mediaobject></para>
 
@@ -757,13 +756,13 @@
 
     <para><mediaobject>
         <imageobject role="fo">
-          <imagedata fileref="images/revengxml_tablescolumn.png" format="png" />
+          <imagedata fileref="images/revengxml_tablescolumn.png" format="PNG" />
         </imageobject>
 
         <imageobject role="html">
           <imagedata align="center"
                      fileref="../shared/images/revengxml_tablescolumn.png"
-                     format="png" />
+                     format="PNG" />
         </imageobject>
       </mediaobject></para>
   </section>
@@ -781,8 +780,6 @@
 
       <title>Viewing the entity structure</title>
 
-       
-
       <para>To view your new configuration and entity/class structure, expand
       the Hibernate Console configuration by clicking on the + icon.</para>
 
@@ -792,7 +789,7 @@
       browse the class/entity structure and see the relationships.</para>
 
        
-
+<para>
       <mediaobject>
         <imageobject role="fo">
           <imagedata fileref="images/queryconsole.png" />
@@ -805,7 +802,7 @@
       </mediaobject>
 
        Hibernate Console perspective showing entity structure, query editor and result 
-
+</para>
       <section>
         <title>Class Diagram</title>
 
@@ -900,7 +897,7 @@
 
           <imageobject role="html">
             <imagedata align="center"
-                       fileref="../shared/images/properties.png" format="png" />
+                       fileref="../shared/images/properties.png" format="PNG" />
           </imageobject>
         </mediaobject></para>
     </section>

Modified: branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/reverseengineering.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/reverseengineering.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/doc/reference/en/modules/reverseengineering.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -422,11 +422,11 @@
 
         <calloutlist>
           <callout arearefs="tablefilter-matchcatalog">
-            <para>catalog (Optional): Catalog name for table</para>
+            <para>catalog (Optional): Catalog name for table. Has to be specified if you are reverse engineering multiple catalogs or if it is not equal to <literal>hiberante.default_catalog</literal></para>
           </callout>
 
           <callout arearefs="tablefilter-matchschema">
-            <para>schema (Optional): Schema name for table</para>
+            <para>schema (Optional): Schema name for table. Has to be specified if you are reverse engineering multiple schemas or if it is not equal to <literal>hiberante.default_schema</literal></para>
           </callout>
 
           <callout arearefs="tablefilter-matchname">

Copied: branches/Lucene_Integration/HibernateExt/tools/lib/jtidy-r8-20060801.jar (from rev 10565, trunk/HibernateExt/tools/lib/jtidy-r8-20060801.jar)

Deleted: branches/Lucene_Integration/HibernateExt/tools/lib/jtidy-r8-21122004.jar
===================================================================
(Binary files differ)

Modified: branches/Lucene_Integration/HibernateExt/tools/lib/testlibs/ejb3-persistence.jar
===================================================================
(Binary files differ)

Modified: branches/Lucene_Integration/HibernateExt/tools/lib/testlibs/hibernate-annotations.jar
===================================================================
(Binary files differ)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -4,6 +4,7 @@
  */
 package org.hibernate.cfg;
 
+
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -40,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;
@@ -137,6 +139,12 @@
                 continue;
                 // TODO: just create one big embedded composite id instead.
             }*/
+			
+			if(revengStrategy.isManyToManyTable(table)) {
+				log.debug( "Ignoring " + table + " as class since rev.eng. says it is a many-to-many" );
+				continue;
+			}				
+				
 			RootClass rc = new RootClass();
 			TableIdentifier tableIdentifier = TableIdentifier.create(table);
 			String className = revengStrategy.tableToClassName( tableIdentifier );
@@ -145,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 {
@@ -169,11 +180,20 @@
 		
 	}
 		
+	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) {
 			for (Iterator iter = foreignKeys.iterator(); iter.hasNext();) {
 				ForeignKey foreignKey = (ForeignKey) iter.next();
-				
+								
 				if(revengStrategy.excludeForeignKeyAsCollection(
 						foreignKey.getName(), 
 						TableIdentifier.create(foreignKey.getTable() ), 
@@ -182,6 +202,7 @@
 						foreignKey.getReferencedColumns())) {
 					log.debug("Rev.eng excluded one-to-many for foreignkey " + foreignKey.getName());
 				} else {
+										
 					Property property = bindOneToMany(rc, foreignKey, processed, mapping);
 					rc.addProperty(property);
 				}
@@ -208,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);
      }
 
 	/**
@@ -222,46 +243,54 @@
 		Table collectionTable = foreignKey.getTable();
 
 		Collection collection = new org.hibernate.mapping.Set(rc); // MASTER TODO: allow overriding collection type
-        
+
 		collection.setCollectionTable(collectionTable); // CHILD+
 		
-		boolean b = isUniqueReference(foreignKey);
 		
-		TableIdentifier foreignKeyTable = TableIdentifier.create( foreignKey.getTable() );
-		TableIdentifier foreignKeyReferencedTable = TableIdentifier.create( foreignKey.getReferencedTable() );
-		String collectionRole = revengStrategy.foreignKeyToCollectionName(
-				foreignKey.getName(),				
-				foreignKeyTable,	
-				foreignKey.getColumns(), 
-				foreignKeyReferencedTable, 
-				foreignKey.getReferencedColumns(), 
-				b
-			);
-        collectionRole = makeUnique(rc,collectionRole);
+		
+		boolean manyToMany = revengStrategy.isManyToManyTable( collectionTable );
+		if(manyToMany) {
+			log.debug("Rev.eng said here is a many-to-many");
+			// TODO: handle "the other side should influence the name"
+		}
         
-		String fullRolePath = StringHelper.qualify(rc.getEntityName(), collectionRole);
-        if (mappings.getCollection(fullRolePath)!=null) {
-            log.debug(fullRolePath + " found twice!");
+
+
+        if(manyToMany) {
+        	
+        	ManyToOne element = new ManyToOne( collection.getCollectionTable() );
+        	//TODO: find the other foreignkey and choose the other side.
+        	Iterator foreignKeyIterator = foreignKey.getTable().getForeignKeyIterator();
+        	List keys = new ArrayList();
+        	while ( foreignKeyIterator.hasNext() ) {
+				Object next = foreignKeyIterator.next();
+				if(next!=foreignKey) {
+					keys.add(next);			
+				}
+			}
+        	
+        	if(keys.size()>1) {
+        		throw new JDBCBinderException("more than one other foreign key to choose from!"); // todo: handle better ?
+        	}
+        	
+        	ForeignKey fk = (ForeignKey) keys.get( 0 );
+
+        	String tableToClassName = bindCollection( rc, foreignKey, fk, collection );
+    		        	
+			element.setReferencedEntityName( tableToClassName );
+			element.addColumn( fk.getColumn( 0 ) );
+			collection.setElement( element );
+			
+        } else {
+        	String tableToClassName = bindCollection( rc, foreignKey, null, collection );
+            
+        	OneToMany oneToMany = new OneToMany( collection.getOwner() );
+        	
+			oneToMany.setReferencedEntityName( tableToClassName ); // Child
+        	mappings.addSecondPass( new JDBCCollectionSecondPass(mappings, collection) );
+        	
+        	collection.setElement(oneToMany);
         }
-        collection.setRole(fullRolePath);  // Master.setOfChildren+ 
-		collection.setInverse(revengStrategy.isForeignKeyCollectionInverse(foreignKey.getName(),				
-				foreignKeyTable,	
-				foreignKey.getColumns(), 
-				foreignKeyReferencedTable, 
-				foreignKey.getReferencedColumns())); // TODO: allow overriding this
-        collection.setLazy(revengStrategy.isForeignKeyCollectionLazy(foreignKey.getName(),				
-				foreignKeyTable,	
-				foreignKey.getColumns(), 
-				foreignKeyReferencedTable, 
-				foreignKey.getReferencedColumns())); 
-        collection.setFetchMode(FetchMode.SELECT);
-        
-		OneToMany oneToMany = new OneToMany( collection.getOwner() );
-		oneToMany.setReferencedEntityName( revengStrategy.tableToClassName( foreignKeyTable ) ); // Child
-		
-        mappings.addSecondPass( new JDBCCollectionSecondPass(mappings, collection) );
-		collection.setElement(oneToMany);
-
 		// bind keyvalue
 		KeyValue referencedKeyValue;
 		String propRef = collection.getReferencedPropertyName();
@@ -289,10 +318,74 @@
 		
 		mappings.addCollection(collection);
 		
-		return makeProperty(collectionRole, collection, true, true, true, "all", null);
+		return makeProperty(TableIdentifier.create( rc.getTable() ), StringHelper.unqualify( collection.getRole() ), collection, true, true, true, "all", null); // TODO: cascade isn't all by default
 		
 	}
 
+	private String bindCollection(PersistentClass rc, ForeignKey fromForeignKey, ForeignKey toForeignKey, Collection collection) {
+		ForeignKey targetKey = fromForeignKey;
+		String collectionRole = null;
+		boolean collectionLazy = false;
+		boolean collectionInverse = false;
+		TableIdentifier foreignKeyTable = null;
+		String tableToClassName;
+		
+		if(toForeignKey!=null) {
+			targetKey = toForeignKey;
+		}
+		
+		boolean uniqueReference = isUniqueReference(targetKey);
+		foreignKeyTable = TableIdentifier.create( targetKey.getTable() );
+		TableIdentifier foreignKeyReferencedTable = TableIdentifier.create( targetKey.getReferencedTable() );
+		
+		if(toForeignKey==null) {
+		
+			collectionRole = revengStrategy.foreignKeyToCollectionName(
+					fromForeignKey.getName(),				
+					foreignKeyTable,	
+					fromForeignKey.getColumns(), 
+					foreignKeyReferencedTable, 
+					fromForeignKey.getReferencedColumns(), 
+					uniqueReference
+			);
+		
+			tableToClassName = revengStrategy.tableToClassName( foreignKeyTable );
+		} else {
+			
+			collectionRole = revengStrategy.foreignKeyToManyToManyName( 
+					fromForeignKey, TableIdentifier.create( fromForeignKey.getTable()), toForeignKey, uniqueReference );
+			
+			tableToClassName = revengStrategy.tableToClassName( foreignKeyReferencedTable );
+		}
+
+		collectionInverse = revengStrategy.isForeignKeyCollectionInverse(targetKey.getName(),				
+				foreignKeyTable,	
+				targetKey.getColumns(), 
+				foreignKeyReferencedTable, 
+				targetKey.getReferencedColumns());
+		
+		collectionLazy = revengStrategy.isForeignKeyCollectionLazy(targetKey.getName(),				
+				foreignKeyTable,	
+				targetKey.getColumns(), 
+				foreignKeyReferencedTable, 
+				targetKey.getReferencedColumns());
+		
+		collectionRole = makeUnique(rc,collectionRole);
+		
+		String fullRolePath = StringHelper.qualify(rc.getEntityName(), collectionRole);
+		if (mappings.getCollection(fullRolePath)!=null) {
+		    log.debug(fullRolePath + " found twice!");
+		}
+		
+		collection.setRole(fullRolePath);  // Master.setOfChildren+ 		
+		collection.setInverse(collectionInverse); // TODO: allow overriding this
+		collection.setLazy(collectionLazy); 
+		collection.setFetchMode(FetchMode.SELECT);
+		
+		
+		return tableToClassName;
+	}
+
 	/** return true if this foreignkey is the only reference from this table to the same foreign table */
     private boolean isUniqueReference(ForeignKey foreignKey) {
 		
@@ -326,10 +419,14 @@
 
 		final TableIdentifier tableIdentifier = TableIdentifier.create(table);
 		
-		String tableIdentifierStrategyName = revengStrategy.getTableIdentifierStrategyName(tableIdentifier);
-		boolean naturalId = "assigned".equals(tableIdentifierStrategyName);
+		String tableIdentifierStrategyName = null;
 		
+		boolean naturalId;
+		
 		if (keyColumns.size()>1) {
+			tableIdentifierStrategyName = "assigned";
+			naturalId = true;
+			
 			id = handleCompositeKey(rc, processed, keyColumns, mapping);
 			idPropertyname = revengStrategy.tableToIdentifierPropertyName(tableIdentifier);
 			if(idPropertyname==null) {
@@ -337,6 +434,8 @@
 			}
 		} 
 		else {
+			tableIdentifierStrategyName = revengStrategy.getTableIdentifierStrategyName(tableIdentifier);
+			naturalId = "assigned".equals( tableIdentifierStrategyName );
 			Column pkc = (Column) keyColumns.get(0);
 			checkColumn(pkc);
 			
@@ -356,13 +455,14 @@
 		}
 		
 		
-		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);
 			
 	}
 
 	/**
+	 * bind many-to-ones
 	 * @param table
 	 * @param rc
 	 * @param primaryKey
@@ -432,7 +532,7 @@
 						processedColumns,
 						mapping
 					);
-				
+								
 				rc.addProperty(property);
 			}			
 		}
@@ -481,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) {
@@ -711,8 +811,8 @@
         }
     }
 
-    private static Property makeProperty(String propertyName, Value value, boolean insertable, boolean updatable, boolean lazy, String cascade, String propertyAccessorName) {
-		log.debug("Building property " + propertyName);
+    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);
 		prop.setValue(value);
@@ -720,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);
-		log.debug("Cascading " + propertyName + " with " + cascade);
+		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
@@ -784,7 +897,7 @@
             PersistentClass persistentClass = mappings.getClass(oneToMany.getReferencedEntityName() ); 
             
             if (persistentClass==null) throw new MappingException(
-                    "Association references unmapped class: " + oneToMany.getReferencedEntityName()
+                    "Association " + collection.getRole() + " references unmapped class: " + oneToMany.getReferencedEntityName()
                 );
             
             oneToMany.setAssociatedClass(persistentClass); // Child            
@@ -809,4 +922,5 @@
             JDBCBinder.bindCollectionSecondPass(collection, persistentClasses, mappings, inheritedMetas);            
         }        
     }
+    	
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCReaderFactory.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCReaderFactory.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCReaderFactory.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -19,6 +19,7 @@
 				.getSQLExceptionConverter(), settings.getDefaultCatalogName(), settings.getDefaultSchemaName(), revengStrategy );
 	}
 
+	//TODO: how to get the current dialect to decide depenendent on the dialect.
 	public static MetaDataDialect newMetaDataDialect(Properties cfg) {
 		String property = cfg.getProperty( "hibernatetool.metadatadialect" );
 		if ( property != null ) {

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,9 +1,12 @@
 package org.hibernate.cfg.reveng;
 
 import java.beans.Introspector;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
@@ -12,6 +15,8 @@
 import org.hibernate.connection.ConnectionProvider;
 import org.hibernate.exception.SQLExceptionConverter;
 import org.hibernate.mapping.Column;
+import org.hibernate.mapping.ForeignKey;
+import org.hibernate.mapping.Table;
 import org.hibernate.util.StringHelper;
 
 public class DefaultReverseEngineeringStrategy implements ReverseEngineeringStrategy {
@@ -155,7 +160,7 @@
 	}
 
 	public boolean useColumnForOptimisticLock(TableIdentifier identifier, String column) {
-		if(settings.hasAutoOptimisticLockDetection()) {
+		if(settings.getDetectOptimsticLock()) {
 			return AUTO_OPTIMISTICLOCK_COLUMNS.contains(column.toLowerCase())?true:false;
 		} else {
 			return false;
@@ -193,5 +198,64 @@
 	public void setSettings(ReverseEngineeringSettings settings) {
 		this.settings = settings;		
 	}
+
+	public boolean isManyToManyTable(Table table) {
+		if(settings.getDetectManyToMany()) {
+			Iterator foreignKeyIterator = table.getForeignKeyIterator();
+			List foreignKeys = new ArrayList();
+			while ( foreignKeyIterator.hasNext() ) {
+				ForeignKey fkey = (ForeignKey) foreignKeyIterator.next();
+				foreignKeys.add( fkey );
+				if(foreignKeys.size()>2) {
+					return false; // early exit if we have more than two fk.
+				}
+			}
+			if(foreignKeys.size()!=2) {
+				return false;
+			}
+			
+			Set columns = new HashSet();
+			Iterator columnIterator = table.getColumnIterator();
+			while ( columnIterator.hasNext() ) {
+				Column column = (Column) columnIterator.next();
+				columns.add(column);
+			}
+		
+			foreignKeyIterator = table.getForeignKeyIterator();
+			while ( !columns.isEmpty() && foreignKeyIterator.hasNext() ) {
+				ForeignKey element = (ForeignKey) foreignKeyIterator.next();				
+				columns.removeAll( element.getColumns() );				
+			}
+			// what if one of the columns is not the primary key?
+			return columns.isEmpty();
+		} else {
+			return false;
+		}
+	}
+
+	public String foreignKeyToManyToManyName(ForeignKey fromKey, TableIdentifier middleTable, ForeignKey toKey, boolean uniqueReference) {
+		String propertyName = Introspector.decapitalize( StringHelper.unqualify( tableToClassName(TableIdentifier.create( toKey.getReferencedTable()) )) );
+		propertyName = pluralize( propertyName );
+		
+		if(!uniqueReference) {
+			//TODO: maybe use the middleTable name here ?
+        	if(toKey.getColumns()!=null && toKey.getColumns().size()==1) {
+        		String columnName = ( (Column) toKey.getColumns().get(0) ).getName();
+        		propertyName = propertyName + "For" + toUpperCamelCase(columnName);
+        	} 
+        	else { // composite key or no columns at all safeguard
+        		propertyName = propertyName + "For" + toUpperCamelCase(toKey.getName()); 
+        	}
+        }
+        return propertyName;      
+	}
+
+	public Map tableToMetaAttributes(TableIdentifier tableIdentifier) {
+		return null;
+	}
+
+	public Map columnToMetaAttributes(TableIdentifier identifier, String column) {
+		return null;
+	}
 	
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DelegatingReverseEngineeringStrategy.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DelegatingReverseEngineeringStrategy.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DelegatingReverseEngineeringStrategy.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,10 +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.Table;
 
 public class DelegatingReverseEngineeringStrategy implements ReverseEngineeringStrategy {
 
@@ -108,6 +111,22 @@
 
 	public void setSettings(ReverseEngineeringSettings settings) {
 		if(delegate!=null) delegate.setSettings(settings);
-	}	
+	}
+
+	public boolean isManyToManyTable(Table table) {
+		return delegate==null?true:delegate.isManyToManyTable( table );
+	}
+
+	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 );
+	}
 	
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -16,7 +16,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.JDBCException;
 import org.hibernate.MappingException;
-import org.hibernate.cfg.JDBCBinder;
 import org.hibernate.cfg.JDBCBinderException;
 import org.hibernate.cfg.reveng.dialect.MetaDataDialect;
 import org.hibernate.connection.ConnectionProvider;
@@ -84,17 +83,24 @@
 			}
 			
 			tables = dbs.iterateTables();
-			Map oneToManyCandidates = new HashMap();
+			List fks = new ArrayList();
 			while ( tables.hasNext() ) {
 				Table table = (Table) tables.next();
 				// Done here after the basic process of collections as we might not have touched 
 				// all referenced tables (this ensure the columns are the same instances througout the basic JDBC derived model.
 				// after this stage it should be "ok" to divert from keeping columns in sync as it can be required if the same 
 				//column is used with different aliases in the ORM mapping.
-				Map foreignKeys = processForeignKeys(dbs, table, progress);
-				mergeMultiMap(oneToManyCandidates, foreignKeys);  	    
+				ForeignKeysInfo foreignKeys = processForeignKeys(dbs, table, progress);
+				fks.add( foreignKeys );				  	   
 			}
 			
+			Map oneToManyCandidates = new HashMap();			
+			for (Iterator iter = fks.iterator(); iter.hasNext();) {
+				ForeignKeysInfo element = (ForeignKeysInfo) iter.next();
+				Map map = element.process( revengStrategy );
+				mergeMultiMap( oneToManyCandidates, map );
+			}
+			
 			dbs.setOneToManyCandidates(oneToManyCandidates);
 			
 			return dbs;
@@ -104,8 +110,43 @@
 		}
 	}
 	
+	static class ForeignKeysInfo {
+		
+		final Map dependentTables;
+		final Map dependentColumns;
+		final Map referencedColumns;
+		private final Table referencedTable;
+		
+		public ForeignKeysInfo(Table referencedTable, Map tables, Map columns, Map refColumns) {
+			this.referencedTable = referencedTable;
+			this.dependentTables = tables;
+			this.dependentColumns = columns;
+			this.referencedColumns = refColumns;
+		}
+		
+		Map process(ReverseEngineeringStrategy revengStrategy) {
+			Map oneToManyCandidates = new HashMap();
+	        Iterator iterator = dependentTables.entrySet().iterator();
+			while (iterator.hasNext() ) {
+				Map.Entry entry = (Map.Entry) iterator.next();
+				String fkName = (String) entry.getKey();
+				Table fkTable = (Table) entry.getValue();			
+				List columns = (List) dependentColumns.get(fkName);
+				List refColumns = (List) referencedColumns.get(fkName);
+				
+				String className = revengStrategy.tableToClassName(TableIdentifier.create(referencedTable) );
+
+				ForeignKey key = fkTable.createForeignKey(fkName, columns, className, refColumns);			
+				key.setReferencedTable(referencedTable);
+
+				addToMultiMap(oneToManyCandidates, className, key);				
+			}
+			// map<className, foreignkey>
+			return oneToManyCandidates;
+		}
+	}
 	
-	protected Map processForeignKeys(DatabaseCollector dbs, Table referencedTable, ProgressListener progress) throws JDBCBinderException {
+	protected ForeignKeysInfo processForeignKeys(DatabaseCollector dbs, Table referencedTable, ProgressListener progress) throws JDBCBinderException {
 		// foreign key name to list of columns
 		Map dependentColumns = new HashMap();
 		// foreign key name to Table
@@ -250,26 +291,9 @@
         }
         
         
-        Map oneToManyCandidates = new HashMap();
-        Iterator iterator = dependentTables.entrySet().iterator();
-		while (iterator.hasNext() ) {
-			Map.Entry entry = (Map.Entry) iterator.next();
-			String fkName = (String) entry.getKey();
-			Table fkTable = (Table) entry.getValue();			
-			List columns = (List) dependentColumns.get(fkName);
-			List refColumns = (List) referencedColumns.get(fkName);
-			
-			String className = revengStrategy.tableToClassName(TableIdentifier.create(referencedTable) );
-			
-			ForeignKey key = fkTable.createForeignKey(fkName, columns, className, refColumns);			
-			key.setReferencedTable(referencedTable);
-			
-			
-			addToMultiMap(oneToManyCandidates, className, key);
-		}
-		// map<className, foreignkey>
-		return oneToManyCandidates;
-	}
+        return new ForeignKeysInfo(referencedTable, dependentTables, dependentColumns, referencedColumns);
+        
+       }
 
 	
 	/**
@@ -688,10 +712,10 @@
 					}								
 				}
 			} 
-			catch (Throwable t) {
+			catch (JDBCException t) {
 				log.warn("Exception while trying to get indexinfo on " + Table.qualify(table.getCatalog(), table.getSchema(), table.getName() ) +  "=" + t.getMessage() );
 				// Bug #604761 Oracle getIndexInfo() needs major grants And other dbs sucks too ;)
-				// http://sourceforge.net/tracker/index.php?func=detail&aid=604761&group_id=36044&atid=415990
+				// http://sourceforge.net/tracker/index.php?func=detail&aid=604761&group_id=36044&atid=415990				
 			} 
 			finally {
 				if (indexIterator != null) {
@@ -755,7 +779,7 @@
 			return false;
 		}
 
-		private void addToMultiMap(Map multimap, String key, Object item) {
+		static private void addToMultiMap(Map multimap, String key, Object item) {
 			List existing = (List) multimap.get(key);
 			if(existing == null) {
 				existing = new ArrayList();

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/MetaAttributeBinder.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/MetaAttributeBinder.java)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideBinder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideBinder.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideBinder.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -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: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -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: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringSettings.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringSettings.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringSettings.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -6,9 +6,10 @@
 	//final ReverseEngineeringStrategy rootStrategy;
 	
 	private String defaultPackageName = "";
-	private boolean autoOptimisticLockDetection = true;
+	private boolean detectOptimisticLock = true;
 	private boolean createCollectionForForeignKey = true;
 	private boolean createManyToOneForForeignKey = true;
+	private boolean detectManyToMany = true;
 	
 	//public ReverseEngineeringSettings(ReverseEngineeringStrategy rootStrategy) {
 	//	this.rootStrategy = rootStrategy;
@@ -29,13 +30,14 @@
 	}
 	
 	/** If true, reverse engineering strategy will try and autodetect columns for optimistc locking, e.g. VERSION and TIMESTAMP */
-	public boolean hasAutoOptimisticLockDetection() {
-		return autoOptimisticLockDetection ;
+	public boolean getDetectOptimsticLock() {
+		return detectOptimisticLock ;
 	}
 	
-	public void setAutoOptimisticLockDetection(
+	public ReverseEngineeringSettings setDetectOptimisticLock(
 			boolean optimisticLockSupportEnabled) {
-		this.autoOptimisticLockDetection = optimisticLockSupportEnabled;
+		this.detectOptimisticLock = optimisticLockSupportEnabled;
+		return this;
 	}
 
 	/** if true, a collection will be mapped for each foreignkey */
@@ -60,7 +62,16 @@
 		this.createManyToOneForForeignKey = createManyToOneForForeignKey;
 		return this;
 	}
+
+	public ReverseEngineeringSettings setDetectManyToMany(boolean b) {
+		this.detectManyToMany = b;
+		return this;
+	}
 	
+	public boolean getDetectManyToMany() {
+		return detectManyToMany;
+	}
+	
 	/** return the top/root strategy. Allows a lower strategy to ask another question. Dangerous to do since recursive loops can easily occur! */
 	/*public ReverseEngineeringStrategy getRootStrategy() {
 		return rootStrategy;

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,10 +1,14 @@
 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 {
 
@@ -33,7 +37,7 @@
 
 	/**
 	 * 
-	 * @return a fully-qualified class name (must be aligned with tableToPackageName and tableToSimpleClassName) 
+	 * @return a fully-qualified class name  
 	 */
 	public String tableToClassName(TableIdentifier tableIdentifier);
 
@@ -43,37 +47,7 @@
 	 * @return a property name
 	 */
 	public String columnToPropertyName(TableIdentifier table, String column);
-
-	/** Should this foreignkey be excluded as a oneToMany */
-	public boolean excludeForeignKeyAsCollection(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns);
-
-	/** Should this foreignkey be excluded as a many-to-one */
-	public boolean excludeForeignKeyAsManytoOne(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns);
-	
-	/** is the collection inverse or not ? */
-	public boolean isForeignKeyCollectionInverse(String name, TableIdentifier foreignKeyTable, List columns, TableIdentifier foreignKeyReferencedTable, List referencedColumns);
-	
-	/** is the collection lazy or not ? */
-	public boolean isForeignKeyCollectionLazy(String name, TableIdentifier foreignKeyTable, List columns, TableIdentifier foreignKeyReferencedTable, List referencedColumns);
-	
-    /**
-     * Return a collection role name for a Collection based on the foreignkey.
-     * @param fromColumns list of Column instances on the fromTable. Only col.getName() should be assumed to be correct 
-     * @param referencedColumns list of Column instances on the referenced Table. Only col.getName() should be assumed to be correct
-     * @param uniqueReference true if there is no other references to the same table
-     * @return
-     */
-    public String foreignKeyToCollectionName(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns, boolean uniqueReference);
-	
-    /**
-     * 
-     * @param fromColumns list of Column instances on the fromTable. Only col.getName() should be assumed to be correct 
-     * @param referencedColumns list of Column instances on the referenced Table. Only col.getName() should be assumed to be correct
-     * @param uniqueReference true if there is no other references to the same table
-     * @return
-     */
-    public String foreignKeyToEntityName(String keyname, TableIdentifier fromTable, List fromColumnNames, TableIdentifier referencedTable, List referencedColumnNames, boolean uniqueReference);
-
+	   
 	public boolean excludeTable(TableIdentifier ti);
 	
 	public boolean excludeColumn(TableIdentifier identifier, String columnName);
@@ -124,19 +98,89 @@
 
 	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);
 
+	/** Should this foreignkey be excluded as a many-to-one */
+	public boolean excludeForeignKeyAsManytoOne(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns);
 	
+	/** is the collection inverse or not ? */
+	public boolean isForeignKeyCollectionInverse(String name, TableIdentifier foreignKeyTable, List columns, TableIdentifier foreignKeyReferencedTable, List referencedColumns);
+	
+	/** is the collection lazy or not ? */
+	public boolean isForeignKeyCollectionLazy(String name, TableIdentifier foreignKeyTable, List columns, TableIdentifier foreignKeyReferencedTable, List referencedColumns);
+	
+    /**
+     * Return a collection role name for a Collection based on the foreignkey.
+     * @param fromColumns list of Column instances on the fromTable. Only col.getName() should be assumed to be correct 
+     * @param referencedColumns list of Column instances on the referenced Table. Only col.getName() should be assumed to be correct
+     * @param uniqueReference true if there is no other references to the same table
+     * @return
+     */
+    public String foreignKeyToCollectionName(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns, boolean uniqueReference);
+	
+    /**
+     * 
+     * @param fromColumns list of Column instances on the fromTable. Only col.getName() should be assumed to be correct 
+     * @param referencedColumns list of Column instances on the referenced Table. Only col.getName() should be assumed to be correct
+     * @param uniqueReference true if there is no other references to the same table
+     * @return
+     */
+    public String foreignKeyToEntityName(String keyname, TableIdentifier fromTable, List fromColumnNames, TableIdentifier referencedTable, List referencedColumnNames, boolean uniqueReference);
 
-		
+	/**
+	 * @param table
+	 * @return true if this table is considered to be a many-to-many table.
+	 */
+	public boolean isManyToManyTable(Table table);
+
+    /**
+     * 
+     * @param middleTable 
+     * @param uniqueReference true if there is no other references to the same table
+     * @param fromColumns list of Column instances on the fromTable. Only col.getName() should be assumed to be correct 
+     * @param referencedColumns list of Column instances on the referenced Table. Only col.getName() should be assumed to be correct
+     * @return
+     */
+    public String foreignKeyToManyToManyName(ForeignKey fromKey, TableIdentifier middleTable, ForeignKey toKey, boolean uniqueReference);
+
+	
+	
+	
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableFilter.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableFilter.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableFilter.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -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;
+	}
 }

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/JDBCMetaDataDialect.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/JDBCMetaDataDialect.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/JDBCMetaDataDialect.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,7 +1,5 @@
 package org.hibernate.cfg.reveng.dialect;
 
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
@@ -9,11 +7,6 @@
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.cfg.JDBCBinderException;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.exception.SQLExceptionConverter;
 import org.hibernate.mapping.Table;
 
 /**
@@ -22,54 +15,15 @@
  * @author Max Rydahl Andersen
  *
  */
-public class JDBCMetaDataDialect implements MetaDataDialect {
+public class JDBCMetaDataDialect extends AbstractMetaDataDialect {
 
-	private static final Log log = LogFactory.getLog(JDBCMetaDataDialect.class);
-
-	private SQLExceptionConverter sec;
-	private ConnectionProvider provider;
 	
-	private Connection connection;
-	private DatabaseMetaData metaData;
-
-		
-	public void configure(ConnectionProvider provider, SQLExceptionConverter sec) {
-		this.provider = provider;
-		this.sec = sec;		
-	}
-	
-	public void close() {
-		metaData = null;
-		if(connection != null) {
-			try {
-				provider.closeConnection(connection);
-			}
-			catch (SQLException e) {
-				sec.convert(e, "Problem while closing connection", null);
-			}
-		}
-		provider = null;
-		sec = null;
-	}
-	
-	protected DatabaseMetaData getMetaData() throws JDBCBinderException {
-		if (metaData == null) {
-			try {
-				metaData = getConnection().getMetaData();				
-			} 
-			catch (SQLException e) {
-				throw sec.convert(e, "Getting database metadata", null);
-			}
-		}
-		return metaData;
-	}
-	
 	public Iterator getTables(final String catalog, final String schema, String table) {
 		try {		
 			log.debug("getTables(" + catalog + "." + schema + "." + table + ")");
 			ResultSet tableRs = getMetaData().getTables(catalog , schema , table, new String[] { "TABLE", "VIEW" });
 			
-			return new ResultSetIterator(tableRs, sec) {
+			return new ResultSetIterator(tableRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet tableRs) throws SQLException {
@@ -83,7 +37,7 @@
 					// schemaRs and catalogRs are only used for error reporting if
 					// we get an exception
 					String databaseStructure = getDatabaseStructure( catalog, schema );
-					throw sec.convert( e,
+					throw getSQLExceptionConverter().convert( e,
 							"Could not get list of tables from database. Probably a JDBC driver problem. "
 									+ databaseStructure, null );					
 				}
@@ -91,7 +45,7 @@
 		} catch (SQLException e) {
 			// schemaRs and catalogRs are only used for error reporting if we get an exception
 			String databaseStructure = getDatabaseStructure(catalog,schema);
-			throw sec.convert(e, "Could not get list of tables from database. Probably a JDBC driver problem. " + databaseStructure, null);		         
+			throw getSQLExceptionConverter().convert(e, "Could not get list of tables from database. Probably a JDBC driver problem. " + databaseStructure, null);		         
 		} 		
 	}
 	
@@ -116,68 +70,15 @@
 		   System.out.println();
 	}
 
-    private String getDatabaseStructure(String catalog, String schema) {
-	      ResultSet schemaRs = null;
-	      ResultSet catalogRs = null;
-	      String nl = System.getProperty("line.separator");
-	      StringBuffer sb = new StringBuffer(nl);
-	      // Let's give the user some feedback. The exception
-	      // is probably related to incorrect schema configuration.
-	      sb.append("Configured schema:").append(schema).append(nl);
-	      sb.append("Configured catalog:").append(catalog ).append(nl);
+    
+	
 
-	      try {
-	         schemaRs = getMetaData().getSchemas();
-	         sb.append("Available schemas:").append(nl);
-	         while (schemaRs.next() ) {
-	            sb.append("  ").append(schemaRs.getString("TABLE_SCHEM") ).append(nl);
-	         }
-	      } 
-	      catch (SQLException e2) {
-	         log.warn("Could not get schemas", e2);
-	         sb.append("  <SQLException while getting schemas>").append(nl);
-	      } 
-	      finally {
-	         try {
-	            schemaRs.close();
-	         } 
-	         catch (Exception ignore) {
-	         }
-	      }
-
-	      try {
-	         catalogRs = getMetaData().getCatalogs();
-	         sb.append("Available catalogs:").append(nl);
-	         while (catalogRs.next() ) {
-	            sb.append("  ").append(catalogRs.getString("TABLE_CAT") ).append(nl);
-	         }
-	      } 
-	      catch (SQLException e2) {
-	         log.warn("Could not get catalogs", e2);
-	         sb.append("  <SQLException while getting catalogs>").append(nl);
-	      } 
-	      finally {
-	         try {
-	            catalogRs.close();
-	         } 
-	         catch (Exception ignore) {
-	         }
-	      }
-	      return sb.toString();
-	   }
-
-	public void close(Iterator iterator) {
-		if(iterator instanceof ResultSetIterator) {
-			((ResultSetIterator)iterator).close();
-		}
-	}
-
 	public Iterator getIndexInfo(final String catalog, final String schema, final String table) {
 		try {		
 			log.debug("getIndexInfo(" + catalog + "." + schema + "." + table + ")");
 			ResultSet tableRs = getMetaData().getIndexInfo(catalog , schema , table, false, true);
 			
-			return new ResultSetIterator(tableRs, sec) {
+			return new ResultSetIterator(tableRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
@@ -190,11 +91,11 @@
 					return element;					
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
 		} 		
 	}
 
@@ -209,7 +110,7 @@
 			log.debug("getColumns(" + catalog + "." + schema + "." + table + "." + column + ")");
 			ResultSet tableRs = getMetaData().getColumns(catalog, schema, table, column);
 			
-			return new ResultSetIterator(tableRs, sec) {
+			return new ResultSetIterator(tableRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
@@ -225,11 +126,11 @@
 					return element;					
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
 		}	
 	}
 
@@ -238,7 +139,7 @@
 			log.debug("getPrimaryKeys(" + catalog + "." + schema + "." + table + ")");
 			ResultSet tableRs = getMetaData().getPrimaryKeys(catalog, schema, table);
 			
-			return new ResultSetIterator(tableRs, sec) {
+			return new ResultSetIterator(tableRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
@@ -250,11 +151,11 @@
 					return element;					
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
 		}	
 	}
 
@@ -263,7 +164,7 @@
 			log.debug("getExportedKeys(" + catalog + "." + schema + "." + table + ")");
 			ResultSet tableRs = getMetaData().getExportedKeys(catalog, schema, table);
 			
-			return new ResultSetIterator(tableRs, sec) {
+			return new ResultSetIterator(tableRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
@@ -281,25 +182,13 @@
 					return element;					
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
 		}	
 	}
 	
-	protected Connection getConnection() throws SQLException {
-		if(connection==null) {
-			connection = provider.getConnection();
-		}
-		return connection;
-	}
-
-	public boolean needQuote(String name) {
-		// TODO: use jdbc metadata to decide on this. but for now we just handle the most typical cases.
-		if(name.indexOf('-')>0) return true;
-		if(name.indexOf(' ')>0) return true;
-		return false;
-	}
+	
 }

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/OracleMetaDataDialect.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/OracleMetaDataDialect.java)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/ResultSetIterator.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/ResultSetIterator.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/ResultSetIterator.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,6 +2,7 @@
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
@@ -20,11 +21,22 @@
 
 	private SQLExceptionConverter sec;
 
+	private Statement statement = null;
+
 	protected ResultSetIterator(ResultSet resultset, SQLExceptionConverter sec) {
+		this(null, resultset, sec);
+	}
+
+	public ResultSetIterator(Statement stmt, ResultSet resultset, SQLExceptionConverter exceptionConverter) {
 		this.rs = resultset;
-		this.sec = sec;
+		this.sec = exceptionConverter;
+		this.statement  = stmt;		
 	}
 
+	protected SQLExceptionConverter getSQLExceptionConverter() {
+		return sec;
+	}
+	
 	public boolean hasNext() {
 		try {
 			advance();
@@ -78,6 +90,9 @@
 	public void close() {
 		try {
 			rs.close();
+			if(statement!=null) {
+				statement.close();
+			}			
 		}
 		catch (SQLException e) {
 			handleSQLException(e);			

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/hibernate-reverse-engineering-3.0.dtd
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/hibernate-reverse-engineering-3.0.dtd	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/hibernate-reverse-engineering-3.0.dtd	2006-10-11 04:01:11 UTC (rev 10566)
@@ -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>
+
+
+

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/Version.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/tool/Version.java)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/EJB3ConfigurationTask.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/EJB3ConfigurationTask.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/EJB3ConfigurationTask.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,62 +0,0 @@
-package org.hibernate.tool.ant;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tools.ant.BuildException;
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.util.ReflectHelper;
-
-public class EJB3ConfigurationTask extends ConfigurationTask {
-
-	public EJB3ConfigurationTask() {
-		setDescription("EJB3 Configuration");
-	}
-	
-	protected Configuration createConfiguration() {
-		try {
-			Map overrides = new HashMap();
-			// set to avoid complain: "The chosen transaction strategy requires access to the JTA TransactionManager "
-			//overrides.put("javax.persistence.transactionType", "RESOURCE_LOCAL");
-
-			Class clazz = ReflectHelper.classForName("org.hibernate.ejb.Ejb3Configuration", EJB3ConfigurationTask.class);
-			Object ejb3cfg = clazz.newInstance();
-			Method method = clazz.getMethod("createEntityManagerFactory", new Class[] { String.class, Map.class });
-			method.invoke(ejb3cfg, new Object[] { null, overrides } );
-			
-			method = clazz.getMethod("getHibernateConfiguration", new Class[0]);
-			return (Configuration) method.invoke(ejb3cfg, null);
-		} 
-		catch(HibernateException he) {
-			throw new BuildException(he);
-		}
-		catch(Throwable t) {
-			throw new BuildException("Problems in creating a Ejb3Configuration. Have you remembered to add it to the classpath ?",t);
-		}
-		
-	}
-	
-	protected void doConfiguration(Configuration configuration) {
-	}
-	
-	protected void validateParameters() throws BuildException {
-		
-	}
-	
-	public void setConfigurationFile(File configurationFile) {
-		complain("configurationfile");
-	}
-
-	public void setEntityResolver(String entityResolverName) {
-		complain("entityresolver");
-	}
-	
-	private void complain(String param) {
-		throw new BuildException("ejb3configuration currently only support autodiscovery from META-INF/persistence.xml. Thus setting the " + param + " attribute is not allowed");
-	}
-	
-	
-}

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/ExporterTask.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/ExporterTask.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/ExporterTask.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -96,8 +96,7 @@
 		exporter.setProperties(prop);
 		exporter.setConfiguration( parent.getConfiguration() );
 		exporter.setOutputDirectory( getDestdir() );
-		exporter.setTemplatePath( getTemplatePath().list() );	
-		if(templatePrefix!=null) exporter.setTemplatePrefix(templatePrefix);
+		exporter.setTemplatePath( getTemplatePath().list() );			
 		return exporter;
 	}
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/GenericExporterTask.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/GenericExporterTask.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/GenericExporterTask.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -4,8 +4,10 @@
  */
 package org.hibernate.tool.ant;
 
+import org.apache.tools.ant.BuildException;
 import org.hibernate.tool.hbm2x.Exporter;
 import org.hibernate.tool.hbm2x.GenericExporter;
+import org.hibernate.util.ReflectHelper;
 
 /**
  * @author max
@@ -21,6 +23,10 @@
 	String exporterClass;
 	String filePattern;
 	
+	/**
+	 * The FilePattern defines the pattern used to generate files.
+	 * @param filePattern
+	 */
 	public void setFilePattern(String filePattern) {
 		this.filePattern = filePattern;
 	}
@@ -33,8 +39,21 @@
 		this.exporterClass = exporterClass;
 	}
 	
-	protected Exporter createExporter() {		
-		return new GenericExporter();
+	protected Exporter createExporter() {
+		if (exporterClass == null) {
+			return new GenericExporter();
+		} else {
+			try {
+				Class theClass = ReflectHelper.classForName(exporterClass);
+				return (Exporter) theClass.newInstance();
+			} catch (ClassNotFoundException e) {
+				throw new BuildException("Could not find custom exporter class: " + exporterClass, e);
+			} catch (InstantiationException e) {
+				throw new BuildException("Could not create custom exporter class: " + exporterClass, e);
+			} catch (IllegalAccessException e) {
+				throw new BuildException("Could not access custom exporter class: " + exporterClass, e);
+			}
+		}		
 	}
 	
 	protected Exporter configureExporter(Exporter exp) {
@@ -42,15 +61,14 @@
 		
 		if(exp instanceof GenericExporter) {
 			GenericExporter exporter = (GenericExporter) exp;
-			exporter.setFilePattern(filePattern);
-			exporter.setTemplateName(templateName);
-			exporter.setExporterClassName(exporterClass);
+			if(filePattern!=null) exporter.setFilePattern(filePattern);
+			if(templateName!=null) exporter.setTemplateName(templateName);			
 		}
 		
 		return exp;
 	}
 
 	public String getName() {
-		return "generic exporter" + ((exporterClass==null) ? "" : exporterClass);
+		return "generic exporter " + ((exporterClass==null) ? "" : exporterClass);
 	}
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/HibernateToolTask.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/HibernateToolTask.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/HibernateToolTask.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -17,6 +17,8 @@
 import org.apache.tools.ant.types.Environment;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.types.PropertySet;
+import org.hibernate.MappingException;
+import org.hibernate.MappingNotFoundException;
 import org.hibernate.cfg.Configuration;
 import org.hibernate.util.StringHelper;
 
@@ -58,12 +60,19 @@
 		return (AnnotationConfigurationTask) configurationTask;			
 	}
 	
-	public EJB3ConfigurationTask createEjb3Configuration() {
+	public JPAConfigurationTask createEjb3Configuration() {
+		log( "<ejb3configuration> is deprecated. Use <jpaconfiguration> instead.", Project.MSG_WARN);
 		checkConfiguration();
-		configurationTask = new EJB3ConfigurationTask();
-		return (EJB3ConfigurationTask) configurationTask;			
+		configurationTask = new JPAConfigurationTask();
+		return (JPAConfigurationTask) configurationTask;			
 	}	
 	
+	public JPAConfigurationTask createJpaConfiguration() {
+		checkConfiguration();
+		configurationTask = new JPAConfigurationTask();
+		return (JPAConfigurationTask) configurationTask;			
+	}	
+	
 	public ExporterTask createHbm2DDL() {
 		ExporterTask generator = new Hbm2DDLExporterTask(this);
 		generators.add(generator);
@@ -141,7 +150,9 @@
 
 	
 	public void execute() {
-		
+		if(configurationTask==null) {
+			throw new BuildException("No configuration specified. <" + getTaskName() + "> must have one of the following: <configuration>, <jpaconfiguration>, <annotationconfiguration> or <jdbcconfiguration>");
+		}
 		log("Executing Hibernate Tool with a " + configurationTask.getDescription() );
 		validateParameters();
 		Iterator iterator = generators.iterator();
@@ -173,6 +184,7 @@
 	private void reportException(Throwable re, int count, ExporterTask generatorTask) {
 		log("An exception occurred while running exporter #" + count + ":" + generatorTask.getName(), Project.MSG_ERR);
 		log("To get the full stack trace run ant with -verbose", Project.MSG_ERR);
+		
 		log(re.toString(), Project.MSG_ERR);
 		String ex = new String();
 		Throwable cause = re.getCause();
@@ -187,6 +199,11 @@
 		if(StringHelper.isNotEmpty(ex)) {
 			log(ex, Project.MSG_ERR);
 		}
+
+		String newbieMessage = getProbableSolutionOrCause(re);
+		if(newbieMessage!=null) {
+			log(newbieMessage);
+		} 		
 		
 		if(re instanceof BuildException) {
 			throw (BuildException)re;
@@ -195,6 +212,50 @@
 		}
 	}
 
+	private String getProbableSolutionOrCause(Throwable re) {
+		if(re==null) return null;
+		
+		if(re instanceof MappingNotFoundException) {
+			MappingNotFoundException mnf = (MappingNotFoundException)re;
+			if("resource".equals(mnf.getType())) {
+				return "A " + mnf.getType() + " located at " + mnf.getPath() + " was not found.\n" +
+						"Check the following:\n" +
+						"\n" +
+						"1) Is the spelling/casing correct ?\n" +
+						"2)	Is " + mnf.getPath() + " available via the classpath ?\n" +
+						"3) Does it actually exist ?\n";						
+			} else {
+				return "A " + mnf.getType() + " located at " + mnf.getPath() + " was not found.\n" +
+				"Check the following:\n" +
+				"\n" +
+				"1) Is the spelling/casing correct ?\n" +
+				"2)	Do you permission to access " + mnf.getPath() + " ?\n" +
+				"3) Does it actually exist ?\n";	
+			}
+		}
+
+		if(re instanceof ClassNotFoundException || re instanceof NoClassDefFoundError) {
+			
+			return "A class were not found in the classpath of the Ant task.\n" +
+					"Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.\n"; 			
+			
+		}
+		
+		if(re instanceof UnsupportedClassVersionError) {
+			return "You are most likely running the ant task with a JRE that is older than the JRE required to use the classes.\n" +
+					"e.g. running with JRE 1.3 or 1.4 when using JDK 1.5 annotations is not possible.\n" +
+					"Ensure that you are using a correct JRE.";
+		}
+		
+		
+		
+		if(re.getCause()!=re) {
+			return getProbableSolutionOrCause( re.getCause() );					
+		}
+		
+		return null;
+	}
+
 	private void validateParameters() {
 		if(generators.isEmpty()) {
 			throw new BuildException("No exporters specified in <hibernatetool>. There has to be at least one specified. An exporter is e.g. <hbm2java> or <hbmtemplate>. See documentation for details.", getLocation());

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/JDBCConfigurationTask.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/JDBCConfigurationTask.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/JDBCConfigurationTask.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -31,6 +31,9 @@
     private String reverseEngineeringStrategyClass;
     private String packageName;
 	private Path revengFiles;
+
+	private boolean detectManyToMany = true;
+	private boolean detectOptimisticLock = true;
     
 	public JDBCConfigurationTask() {
 		setDescription("JDBC Configuration (for reverse engineering)");
@@ -49,7 +52,10 @@
         jmdc.setPreferBasicCompositeIds(preferBasicCompositeIds);
 
 		DefaultReverseEngineeringStrategy defaultStrategy = new DefaultReverseEngineeringStrategy();
-		ReverseEngineeringSettings qqsettings = new ReverseEngineeringSettings().setDefaultPackageName(packageName);
+		ReverseEngineeringSettings qqsettings = 
+				new ReverseEngineeringSettings().setDefaultPackageName(packageName)
+				.setDetectManyToMany( detectManyToMany )
+				.setDetectOptimisticLock( detectOptimisticLock );
 		
         if(packageName!=null) {
             defaultStrategy.setSettings(qqsettings);
@@ -93,6 +99,14 @@
 		preferBasicCompositeIds = b;
 	}
 	
+	public void setDetectManyToMany(boolean b) {
+		detectManyToMany = b;
+	}
+	
+	public void setDetectOptimisticLock(boolean b) {
+		detectOptimisticLock = b;
+	}
+	
     private ReverseEngineeringStrategy loadreverseEngineeringStrategy(final String className, ReverseEngineeringStrategy delegate) 
     throws BuildException {
         try {

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/ant/JPAConfigurationTask.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/tool/ant/JPAConfigurationTask.java)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/AbstractExporter.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/AbstractExporter.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/AbstractExporter.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -36,8 +36,6 @@
 	private Cfg2HbmTool c2h;
 	private Cfg2JavaTool c2j;
 
-	private String templatePrefix = null;
-
 	public AbstractExporter(Configuration cfg, File outputdir) {
 		this();
 		setConfiguration(cfg);
@@ -86,6 +84,10 @@
 		return configuration;
 	}
 
+	/**
+	 * Builds template context and performs file generation
+	 * Subclasses mostly implement doStart() instead.
+	 */
 	public void start() {
 		setTemplateHelper( new TemplateHelper() );
 		setupTemplates();
@@ -96,7 +98,7 @@
 		getArtifactCollector().formatFiles();
 	}
 	
-	abstract public void doStart();
+	abstract protected void doStart();
 
 	public String[] getTemplatePaths() {
 		return templatePaths;
@@ -129,18 +131,11 @@
  
 	protected void setupTemplates() {
 		if(log.isDebugEnabled()) {
-			log.debug(getClass().getName() + " outputdir:" + getOutputDirectory() + " templatePrefix: " + getTemplatePrefix()  + " path: " + toString(templatePaths) );
+			log.debug(getClass().getName() + " outputdir:" + getOutputDirectory() + " path: " + toString(templatePaths) );
 		}
-		getTemplateHelper().init(getOutputDirectory(), getTemplatePrefix(), templatePaths);		
+		getTemplateHelper().init(getOutputDirectory(), templatePaths);		
 	}
 
-	final public String getTemplatePrefix() {
-		return templatePrefix ; // default to not have any prefix
-	}
-
-	public void setTemplatePrefix(String t) {
-		this.templatePrefix = t;
-	}
 	/**
 	 * Setup the context variables used by the exporter. Subclasses should call super.setupContext() to ensure all needed variables are in the context. 
 	 **/
@@ -229,6 +224,7 @@
 	
 	public void setProperties(Properties properties) {
 		this.properties = properties;
+		
 	}
 
 	public void setArtifactCollector(ArtifactCollector collector) {

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -16,15 +16,35 @@
 import org.hibernate.engine.query.sql.NativeSQLQueryJoinReturn;
 import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
 import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
+import org.hibernate.mapping.Any;
+import org.hibernate.mapping.Array;
+import org.hibernate.mapping.Bag;
 import org.hibernate.mapping.Collection;
 import org.hibernate.mapping.Column;
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.DependantValue;
 import org.hibernate.mapping.Formula;
+import org.hibernate.mapping.IdentifierBag;
+import org.hibernate.mapping.JoinedSubclass;
+import org.hibernate.mapping.List;
 import org.hibernate.mapping.ManyToOne;
 import org.hibernate.mapping.OneToMany;
+import org.hibernate.mapping.OneToOne;
 import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.PersistentClassVisitor;
+import org.hibernate.mapping.PrimitiveArray;
 import org.hibernate.mapping.Property;
+import org.hibernate.mapping.RootClass;
 import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.SingleTableSubclass;
+import org.hibernate.mapping.Subclass;
+import org.hibernate.mapping.UnionSubclass;
 import org.hibernate.mapping.Value;
+import org.hibernate.mapping.ValueVisitor;
+import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
+import org.hibernate.persister.entity.SingleTableEntityPersister;
+import org.hibernate.persister.entity.UnionSubclassEntityPersister;
+import org.hibernate.tool.hbm2x.visitor.EntityNameFromValueVisitor;
 import org.hibernate.tool.hbm2x.visitor.HBMTagForPersistentClassVisitor;
 import org.hibernate.tool.hbm2x.visitor.HBMTagForValueVisitor;
 
@@ -33,6 +53,38 @@
  */
 public class Cfg2HbmTool {
 
+	private final class HasEntityPersisterVisitor implements PersistentClassVisitor {
+		private final String name;
+
+		private HasEntityPersisterVisitor(String name) {
+			this.name = name;
+		}
+
+		public Object accept(Subclass subclass) {
+			return bool(!SingleTableEntityPersister.class.getName().equals(name));
+		}
+
+		private Object bool(boolean b) {
+			return Boolean.valueOf( b );
+		}
+
+		public Object accept(JoinedSubclass subclass) {
+			return bool(!JoinedSubclassEntityPersister.class.getName().equals(name));
+		}
+
+		public Object accept(SingleTableSubclass subclass) {
+			return bool(!SingleTableEntityPersister.class.getName().equals(name));							
+		}
+
+		public Object accept(UnionSubclass subclass) {
+			return bool(!UnionSubclassEntityPersister.class.getName().equals(name));
+		}
+
+		public Object accept(RootClass class1) {
+			return bool(!SingleTableEntityPersister.class.getName().equals(name));
+		}
+	}
+
 	public String getTag(PersistentClass pc) {
 		return (String) pc.accept(HBMTagForPersistentClassVisitor.INSTANCE);
 	}
@@ -276,4 +328,37 @@
 	public boolean isImportData(Configuration cfg) {
 		return !(cfg.getImports().isEmpty());
 	}
+
+	public boolean needsDiscriminator(PersistentClass clazz) {
+		
+		return clazz instanceof Subclass 
+		  && !(clazz instanceof UnionSubclass) && !(clazz instanceof JoinedSubclass);
+	}
+
+
+	public boolean needsTable(PersistentClass clazz) {
+		return !(clazz instanceof org.hibernate.mapping.Subclass
+				 && clazz instanceof org.hibernate.mapping.SingleTableSubclass);
+	}
+
+	public boolean isSubclass(PersistentClass clazz) {
+		return clazz instanceof org.hibernate.mapping.Subclass;
+	}
+	
+	public boolean isJoinedSubclass(PersistentClass clazz) {
+		return clazz instanceof JoinedSubclass;
+	}
+	
+	public boolean hasCustomEntityPersister(PersistentClass clazz) {
+		Class entityPersisterClass = clazz.getEntityPersisterClass();
+		if(entityPersisterClass==null) return false;
+		final String name = entityPersisterClass.getName();
+			
+		Boolean object = (Boolean) clazz.accept( new HasEntityPersisterVisitor( name ) );
+		return object.booleanValue();
+	}
+
+	public String getHibernateTypeName(Property p) {
+		return (String) p.getValue().accept(new EntityNameFromValueVisitor());
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -35,6 +35,7 @@
 import org.hibernate.tool.hbm2x.pojo.ImportContext;
 import org.hibernate.tool.hbm2x.pojo.NoopImportContext;
 import org.hibernate.tool.hbm2x.pojo.POJOClass;
+import org.hibernate.tool.hbm2x.visitor.JavaTypeFromValueVisitor;
 import org.hibernate.type.CompositeCustomType;
 import org.hibernate.type.CustomType;
 import org.hibernate.type.PrimitiveType;
@@ -206,7 +207,7 @@
 
 	private static Set NONPRIMITIVETYPES = null;
 
-	boolean isNonPrimitiveTypeName(String typeName) {
+	static public boolean isNonPrimitiveTypeName(String typeName) {
 		if ( NONPRIMITIVETYPES == null ) {
 			NONPRIMITIVETYPES = new HashSet();
 			Field[] fields = Hibernate.class.getFields();
@@ -297,6 +298,7 @@
 	}
 
 	private String getJavaTypeName(Value value, boolean preferRawTypeNames) {
+		if(true) return (String) value.accept( new JavaTypeFromValueVisitor() );
 		if ( value instanceof Component) {
 			// composite-element breaks without it.
 			return ((Component)value).getComponentClassName();
@@ -392,7 +394,7 @@
 		return asArgumentList( fields.iterator() );
 	}
 	
-	public String asFinderArgumentList(Map parameterTypes, PersistentClass clazz) {
+	public String asFinderArgumentList(Map parameterTypes, ImportContext ctx) {
 		StringBuffer buf = new StringBuffer();
 		Iterator iter = parameterTypes.entrySet().iterator();
 		while ( iter.hasNext() ) {
@@ -418,7 +420,7 @@
 				}
 				typename = typeClass.getName();
 			}
-			buf.append( typename )
+			buf.append( ctx.importType( typename ))
 					.append( " " )
 					.append( entry.getKey() );
 			if ( iter.hasNext() ) buf.append( ", " );

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DAOExporter.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DAOExporter.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DAOExporter.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -8,7 +8,7 @@
 
 public class DAOExporter extends POJOExporter {
 
-    private static final String DAO_DAOHOME_VM = "daohome.ftl";
+    private static final String DAO_DAOHOME_FTL = "dao/daohome.ftl";
 
     private String sessionFactoryName = "SessionFactory";
 
@@ -21,9 +21,8 @@
 
     protected void init() {
     	super.init();
-    	setTemplateName(DAO_DAOHOME_VM);
-    	setFilePattern("{package-name}/{class-name}Home.java");
-    	setTemplatePrefix("dao/");    	
+    	setTemplateName(DAO_DAOHOME_FTL);
+    	setFilePattern("{package-name}/{class-name}Home.java");    	    	
     }
     
     protected void exportComponent(Map additionalContext, POJOClass element) {

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DAONewExporter.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DAONewExporter.java)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,18 +1,23 @@
 package org.hibernate.tool.hbm2x;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.hibernate.HibernateException;
 import org.hibernate.cfg.Configuration;
 import org.hibernate.mapping.Table;
 import org.hibernate.tool.hbm2x.doc.DocFile;
 import org.hibernate.tool.hbm2x.doc.DocFileManager;
 import org.hibernate.tool.hbm2x.doc.DocHelper;
 import org.hibernate.tool.hbm2x.pojo.POJOClass;
+import org.hibernate.util.StringHelper;
 
 /**
  * Exporter implementation that creates Hibernate Documentation.
@@ -47,67 +52,67 @@
     /**
      * Template used for the index of the table documentation.
      */
-    private static final String VM_TABLES_INDEX = "doc/tables/index.ftl";
+    private static final String FTL_TABLES_INDEX = "doc/tables/index.ftl";
     
     /**
      * Template used for index of the entity documentation
      */
-    private static final String VM_ENTITIES_INDEX = "doc/entities/index.ftl";
+    private static final String FTL_ENTITIES_INDEX = "doc/entities/index.ftl";
     
     /**
      * Template used for the Classes Summary
      */
-    private static final String VM_ENTITIES_SUMMARY = "doc/entities/summary.ftl";
+    private static final String FTL_ENTITIES_SUMMARY = "doc/entities/summary.ftl";
     
     /**
      * Template used for Class details
      */
-    private static final String VM_ENTITIES_ENTITY = "doc/entities/entity.ftl";
+    private static final String FTL_ENTITIES_ENTITY = "doc/entities/entity.ftl";
     
     /**
      * Template used to create the Package List
      */
-    private static final String VM_ENTITIES_PACKAGE_LIST = "doc/entities/package-list.ftl";
+    private static final String FTL_ENTITIES_PACKAGE_LIST = "doc/entities/package-list.ftl";
     
     /**
      * Template used to create the list of all Classes
      */
-    private static final String VM_ENTITIES_ENTITY_LIST = "doc/entities/allEntity-list.ftl";
+    private static final String FTL_ENTITIES_ENTITY_LIST = "doc/entities/allEntity-list.ftl";
     
     /**
      * Template used to create List of Classes specific to packages.
      */
-    private static final String VM_ENTITIES_PERPACKAGE_ENTITY_LIST = "doc/entities/perPackageEntity-list.ftl";
+    private static final String FTL_ENTITIES_PERPACKAGE_ENTITY_LIST = "doc/entities/perPackageEntity-list.ftl";
     
     /**
      * Template used to show the specific package details
      */
-    private static final String VM_ENTITIES_PACKAGE_SUMMARY = "doc/entities/package-summary.ftl";
+    private static final String FTL_ENTITIES_PACKAGE_SUMMARY = "doc/entities/package-summary.ftl";
 
     /**
      * Template used for the Tables Summary.
      */
-    private static final String VM_TABLES_SUMMARY = "doc/tables/summary.ftl";
+    private static final String FTL_TABLES_SUMMARY = "doc/tables/summary.ftl";
 
     /**
      * Template used for table lists.
      */
-    private static final String VM_TABLES_TABLE_LIST = "doc/tables/table-list.ftl";
+    private static final String FTL_TABLES_TABLE_LIST = "doc/tables/table-list.ftl";
 
     /**
      * Template used for schema lists.
      */
-    private static final String VM_TABLES_SCHEMA_LIST = "doc/tables/schema-list.ftl";
+    private static final String FTL_TABLES_SCHEMA_LIST = "doc/tables/schema-list.ftl";
 
     /**
      * Template used for Schema Summary.
      */
-    private static final String VM_TABLES_SCHEMA_SUMMARY = "doc/tables/schema-summary.ftl";
+    private static final String FTL_TABLES_SCHEMA_SUMMARY = "doc/tables/schema-summary.ftl";
 
     /**
      * Template used for the Table Details.
      */
-    private static final String VM_TABLES_TABLE = "doc/tables/table.ftl";
+    private static final String FTL_TABLES_TABLE = "doc/tables/table.ftl";
 
     /**
      * Doc helper.
@@ -142,8 +147,10 @@
 
 	public void doStart() throws ExporterException {
         generateCommmonAndAssets();
+        
+        boolean graphsGenerated = generateDot();
         generateTablesIndex();
-        generateTablesSummary();
+        generateTablesSummary(graphsGenerated);
         generateTablesDetails();
         generateTablesAllSchemasList();
         generateTablesAllTablesList();
@@ -151,14 +158,117 @@
         generateTablesSchemaDetailedInfo();
         
         generateEntitiesIndex();
-        generatePackageSummary();
+        generatePackageSummary(graphsGenerated);
         generateEntitiesDetails();
         generateEntitiesAllPackagesList();
         generateEntitiesAllEntitiesList();
         generateEntitiesPackageEntityList();
         generateEntitiesPackageDetailedInfo();
+        
+        
     }
 
+	private boolean generateDot() {
+		String cmd = getProperties().getProperty( "dot.executable" );
+		
+		if(StringHelper.isNotEmpty( cmd )) {
+			try {
+				GenericExporter exporter = new GenericExporter(getConfiguration(), getOutputDirectory());
+				exporter.setTemplateName( "dot/entitygraph.dot.ftl" );
+				exporter.setFilePattern( "entities/entitygraph.dot" );
+				exporter.setArtifactCollector( getArtifactCollector() );
+				exporter.setProperties( getProperties() );
+				exporter.setTemplatePath( getTemplatePaths() );
+				exporter.start();
+
+				exporter.setTemplateName( "dot/tablegraph.dot.ftl" );
+				exporter.setFilePattern( "tables/tablegraph.dot" );
+				exporter.setProperties( getProperties() );
+				exporter.start();
+				
+				dotToFile( cmd, new File(getOutputDirectory(), "entities/entitygraph.dot").toString(), new File(getOutputDirectory(), "entities/entitygraph.png").toString());
+				dotToFile( cmd, new File(getOutputDirectory(), "entities/entitygraph.dot").toString(), new File(getOutputDirectory(), "entities/entitygraph.svg").toString());
+				dotToFile( cmd, new File(getOutputDirectory(), "entities/entitygraph.dot").toString(), new File(getOutputDirectory(), "entities/entitygraph.cmap").toString());
+				
+				dotToFile( cmd, new File(getOutputDirectory(), "tables/tablegraph.dot").toString(), new File(getOutputDirectory(), "tables/tablegraph.png").toString());
+				dotToFile( cmd, new File(getOutputDirectory(), "tables/tablegraph.dot").toString(), new File(getOutputDirectory(), "tables/tablegraph.svg").toString());
+				dotToFile( cmd, new File(getOutputDirectory(), "tables/tablegraph.dot").toString(), new File(getOutputDirectory(), "tables/tablegraph.cmap").toString());
+			
+				return true;
+
+			}
+			catch (IOException e) {
+				throw new HibernateException("Problem while generating DOT graph for Configuration", e);
+			}
+		} else {
+			log.info( "Skipping entitygraph creation since dot.executable is empty or not-specified." );
+			return false;
+		}
+	}
+
+	public static final String OS_NAME = System.getProperty("os.name");    
+    public static final boolean IS_LINUX = OS_NAME.startsWith("Linux");    
+	
+	private String escape(String fileName){
+		
+		// Linux does not need " " around file names
+		if (IS_LINUX){
+			return fileName;
+		}
+		
+		// Windows needs " " around file names; actually we do not 
+		// need it always, only when spaces are present;
+		// but it does not hurt to usem them always
+		return "\"" + fileName + "\"";
+		
+	}
+	
+	private void dotToFile(String dotExeFileName, String dotFileName, String outFileName) throws IOException {
+
+		//
+		// dot.exe works by taking *.dot file and piping 
+		// results into another file, for example:
+		// d:\graphviz-1.12\bin\dot.exe -Tgif c:\temp\ManualDraw.dot > c:\temp\ManualDraw.gif
+		// so we follow that model here and read stdout until EOF
+		// 
+	
+		final String exeCmd = 
+			escape(dotExeFileName) + 
+			" -T" + getFormatForFile(outFileName) + " " + 
+			escape(dotFileName) +
+			" -o " + 
+			escape(outFileName);			
+	
+		Process p = Runtime.getRuntime().exec(exeCmd);
+		//p.getErrorStream().
+		try {
+			log.debug( "Executing: " + exeCmd );
+//			 Get the input stream and read from it
+	        InputStream in = p.getErrorStream();
+	        int c;
+	        while ((c = in.read()) != -1) {
+	            System.out.print((char)c);
+	        }
+	        in.close();
+			int i = p.waitFor( );
+			if(i!=0) {
+				//TODO: dump system.err
+				log.error("Error " + i + " while executing: " + exeCmd);				
+			}
+		} catch(Exception ie){
+			log.error( "Error while executing: " + exeCmd, ie );
+		}
+	}		
+
+	private String getFormatForFile(String outFileName){
+		int idx = outFileName.lastIndexOf(".");
+		if (idx == -1 || idx == outFileName.length() - 1){
+			throw new IllegalArgumentException("Can't determine file name extention for file name " + outFileName); 
+		}
+		return outFileName.substring(idx + 1);
+	}
+	
+
 	protected void setupContext() {
 		getProperties().put("jdk5", "" + useJdk5());
 		super.setupContext();
@@ -207,7 +317,7 @@
         Map parameters = new HashMap();
         parameters.put("docFile", docFile);
 
-        processTemplate(parameters, VM_TABLES_INDEX, file);
+        processTemplate(parameters, FTL_TABLES_INDEX, file);
     }
     
     /**
@@ -218,28 +328,51 @@
     	File file = docFile.getFile();
     	Map parameters = new HashMap();
     	parameters.put("docFile", docFile);
-    	processTemplate(parameters, VM_ENTITIES_INDEX, file );
+    	processTemplate(parameters, FTL_ENTITIES_INDEX, file );
     }
 
     /**
      * Generate a file with an summary of all the tables.
+     * @param graphsGenerated 
      */
-    public void generateTablesSummary() {
+    public void generateTablesSummary(boolean graphsGenerated) {
         DocFile docFile = docFileManager.getTableSummaryDocFile();
 
         File file = docFileManager.getTableSummaryDocFile().getFile();
 
         Map parameters = new HashMap();
         parameters.put("docFile", docFile);
+        parameters.put( "graphsGenerated", Boolean.valueOf( graphsGenerated ) );
+        if(graphsGenerated) {
+        	StringBuffer sb = new StringBuffer();
+        	String fileName = "tables/tablegraph.cmap";
+        	appendFile( sb, fileName );
+            parameters.put( "tablegrapharea", sb );
+        }
+        
+        processTemplate(parameters, FTL_TABLES_SUMMARY, file);
+    }
 
-        processTemplate(parameters, VM_TABLES_SUMMARY, file);
-    }
+	private void appendFile(StringBuffer sb, String fileName) {
+		try {
+			BufferedReader in = new BufferedReader(new FileReader(new File(getOutputDirectory(), fileName)));
+		    String str;
+		    
+		    while ((str = in.readLine()) != null) {
+		        sb.append(str);
+		        sb.append(System.getProperty("line.separator"));
+		    }
+		    
+		    in.close();
+		} catch (IOException e) {
+		}
+	}
     
     /**
      * Generate summary (summaty.html) to show all the packages 
      *
      */
-    public void generatePackageSummary(){
+    public void generatePackageSummary(boolean graphsGenerated){
     	DocFile docFile = docFileManager.getClassSummaryFile(); 
     	File file = docFile.getFile();
     	
@@ -250,8 +383,15 @@
         //Remove All Classes
         list.remove(0);
         parameters.put("packageList", list );
-        
-    	processTemplate(parameters, VM_ENTITIES_SUMMARY, file);
+        parameters.put( "graphsGenerated", Boolean.valueOf( graphsGenerated ) );
+        if(graphsGenerated) {
+        	StringBuffer sb = new StringBuffer();
+        	String fileName = "entities/entitygraph.cmap";
+        	appendFile( sb, fileName );
+            parameters.put( "entitygrapharea", sb );
+        }
+
+    	processTemplate(parameters, FTL_ENTITIES_SUMMARY, file);
     }
 
     /**
@@ -263,14 +403,15 @@
             Table table = (Table) tables.next();
 
             DocFile docFile = docFileManager.getTableDocFile(table);
+            if(docFile!=null) {
+            	File file = docFile.getFile();
 
-            File file = docFile.getFile();
+            	Map parameters = new HashMap();
+            	parameters.put("docFile", docFile);
+            	parameters.put("table", table);
 
-            Map parameters = new HashMap();
-            parameters.put("docFile", docFile);
-            parameters.put("table", table);
-
-            processTemplate(parameters, VM_TABLES_TABLE, file);
+            	processTemplate(parameters, FTL_TABLES_TABLE, file);
+            }
         }
     }
    
@@ -290,7 +431,7 @@
     		Map parameters = new HashMap();
     		parameters.put("docFile", docFile);
     		parameters.put("class", pcObj);    		
-    		processTemplate(parameters, VM_ENTITIES_ENTITY, file);
+    		processTemplate(parameters, FTL_ENTITIES_ENTITY, file);
     	}
     }
     
@@ -311,7 +452,7 @@
         list.remove(0);
         parameters.put("packageList", list );
 
-        processTemplate(parameters, VM_ENTITIES_PACKAGE_LIST, file);
+        processTemplate(parameters, FTL_ENTITIES_PACKAGE_LIST, file);
     } 
     
     /**
@@ -328,7 +469,7 @@
         parameters.put("title", "All Entities");
         parameters.put("classList", docHelper.getClasses());  
 
-        processTemplate(parameters, VM_ENTITIES_ENTITY_LIST, file);
+        processTemplate(parameters, FTL_ENTITIES_ENTITY_LIST, file);
     }
     
     /**
@@ -349,7 +490,7 @@
                 parameters.put("docFile", docFile);
                 parameters.put("title", packageName);
                 parameters.put("classList", docHelper.getClasses(packageName));
-                processTemplate(parameters, VM_ENTITIES_PERPACKAGE_ENTITY_LIST, file);
+                processTemplate(parameters, FTL_ENTITIES_PERPACKAGE_ENTITY_LIST, file);
             	
             }
 
@@ -374,7 +515,7 @@
             parameters.put("package", packageName);           
             parameters.put("classList", docHelper.getClasses(packageName));                       
 
-            processTemplate(parameters, VM_ENTITIES_PACKAGE_SUMMARY,
+            processTemplate(parameters, FTL_ENTITIES_PACKAGE_SUMMARY,
                     summaryDocFile.getFile() );
         }
     }    
@@ -392,7 +533,7 @@
         parameters.put("title", "Schema List");
         parameters.put("schemaList", docHelper.getSchemas() );
 
-        processTemplate(parameters, VM_TABLES_SCHEMA_LIST, file);
+        processTemplate(parameters, FTL_TABLES_SCHEMA_LIST, file);
     }
 
     /**
@@ -408,7 +549,7 @@
         parameters.put("title", "All Tables");
         parameters.put("tableList", docHelper.getTables() );
 
-        processTemplate(parameters, VM_TABLES_TABLE_LIST, file);
+        processTemplate(parameters, FTL_TABLES_TABLE_LIST, file);
     }
 
     public void generateTablesSchemaTableList() {
@@ -426,7 +567,7 @@
             parameters.put("title", "Tables for " + schemaName);
             parameters.put("tableList", docHelper.getTables(schemaName) );
 
-            processTemplate(parameters, VM_TABLES_TABLE_LIST, file);
+            processTemplate(parameters, FTL_TABLES_TABLE_LIST, file);
         }
     }
 
@@ -445,7 +586,7 @@
             parameters.put("docFile", summaryDocFile);
             parameters.put("schema", schemaName);
 
-            processTemplate(parameters, VM_TABLES_SCHEMA_SUMMARY,
+            processTemplate(parameters, FTL_TABLES_SCHEMA_SUMMARY,
                     summaryDocFile.getFile() );
 
             DocFile tableListDocFile = docFileManager.getSchemaSummaryDocFile(schemaName);
@@ -454,8 +595,10 @@
             parameters.put("docFile", tableListDocFile);
             parameters.put("schema", schemaName);
 
-            processTemplate(parameters, VM_TABLES_SCHEMA_SUMMARY,
+            processTemplate(parameters, FTL_TABLES_SCHEMA_SUMMARY,
                     tableListDocFile.getFile() );
+            
+            //processTemplate( new HashMap(), templateName, outputFile );
         }
     }
 

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Exporter.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Exporter.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Exporter.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -14,20 +14,48 @@
  */
 public interface Exporter {
 		
+	/** 
+	 * @param cfg An Hibernate {@link org.hibernate.Configuration} or subclass instance that defines the hibernate meta model to be exported.
+	 */
 	public void setConfiguration(Configuration cfg);
-	
+
+	/**
+	 * @param file basedirectory to be used for generated files.
+	 */
 	public void setOutputDirectory(File file);
-	
+
+	/**
+	 * @param templatePath array of directories used sequentially to lookup templates
+	 */
 	public void setTemplatePath(String[] templatePath);
 	
-	public void setTemplatePrefix(String templatePrefix);
-	
+	/**
+	 * @param templatePrefix template prefix to be used. e.g. if set to "dao/", "dao/" will be prefixed all lookups before the simple name will looked up. Used to allow seperation of templates within a templatepath.  
+	 */
+//	public void setTemplatePrefix(String templatePrefix);
+
+	/**
+	 * 
+	 * @param properties set of properties to be used by exporter.
+	 */
 	public void setProperties(Properties properties);
 	
 	
+	/**
+	 * 
+	 * @param collector Instance to be consulted when adding a new file.
+	 */
 	public void setArtifactCollector(ArtifactCollector collector);
+	
+	/**
+	 * 
+	 * @return artifact collector
+	 */
 	public ArtifactCollector getArtifactCollector();
 	
+	/**
+	 * Called when exporter should start generating its output
+	 */
 	public void start();
 	
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/GenericExporter.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/GenericExporter.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/GenericExporter.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -4,21 +4,18 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Properties;
 
 import org.hibernate.cfg.Configuration;
 import org.hibernate.mapping.Component;
 import org.hibernate.tool.hbm2x.pojo.ComponentPOJOClass;
 import org.hibernate.tool.hbm2x.pojo.POJOClass;
-import org.hibernate.util.ReflectHelper;
 import org.hibernate.util.StringHelper;
 
 
 public class GenericExporter extends AbstractExporter {
 
-	String templateName;
+	private String templateName;
 	private String filePattern;
-	private String exporterClassName;
 	
 	public GenericExporter(Configuration cfg, File outputdir) {
 		super(cfg,outputdir);
@@ -34,36 +31,11 @@
 	public void setTemplateName(String templateName) {
 		this.templateName = templateName;
 	}
-		
-	public void start() {
-		if(exporterClassName!=null) {
-			Exporter exporter = null;
-			try {
-				Class exporterClass = ReflectHelper.classForName(exporterClassName);
-				exporter = (Exporter) exporterClass.newInstance();
-				Properties p = getProperties();
-				if(getTemplateName()!=null) p.put(ExporterSettings.PREFIX_KEY + "template_name", getTemplateName());
-				if(filePattern!=null) p.put(ExporterSettings.PREFIX_KEY + "file_pattern", filePattern);
-				exporter.setProperties(getProperties());
-				exporter.setArtifactCollector(getArtifactCollector());
-				exporter.setConfiguration(getConfiguration());
-				exporter.setOutputDirectory(getOutputDirectory());
-				exporter.setTemplatePath(getTemplatePaths());							
-			}
-			catch (Exception e) {
-				throw new ExporterException("Could not instantiate/configure exporter of class " + exporterClassName,e);
-			}
 			
-			exporter.start();
-		} else {
-			super.start();
-		}
-	}
-	
-	public void doStart() {
+	protected void doStart() {
 				
-		if(filePattern==null) throw new ExporterException("File pattern not set on GenericExporter");
-		if(templateName==null) throw new ExporterException("Template pattern not set on GenericExporter");
+		if(filePattern==null) throw new ExporterException("File pattern not set on " + this.getClass());
+		if(templateName==null) throw new ExporterException("Template pattern not set on " + this.getClass());
 		
 		if(filePattern.indexOf("{class-name}")>=0) {				
 			exportClasses();
@@ -133,8 +105,8 @@
 	public void setFilePattern(String filePattern) {
 		this.filePattern = filePattern;		
 	}
-
-	public void setExporterClassName(String exporterClassName) {
-		this.exporterClassName = exporterClassName;
+	
+	public String getFilePattern() {
+		return filePattern;
 	}
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/HibernateMappingExporter.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/HibernateMappingExporter.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/HibernateMappingExporter.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -39,7 +39,7 @@
 		Configuration cfg = getConfiguration();
 		if(c2h.isImportData(cfg) && (c2h.isNamedQueries(cfg)) && (c2h.isNamedSQLQueries(cfg)) && (c2h.isFilterDefinitions(cfg))) {
 			TemplateProducer producer = new TemplateProducer(getTemplateHelper(),getArtifactCollector());
-			producer.produce(new HashMap(), "generalhbm.hbm.ftl", new File(getOutputDirectory(),"GeneralHbmSettings.hbm.xml"), templateName);
+			producer.produce(new HashMap(), "hbm/generalhbm.hbm.ftl", new File(getOutputDirectory(),"GeneralHbmSettings.hbm.xml"), getTemplateName());
 		}
 	}
 	
@@ -49,9 +49,8 @@
     }
     
 	protected void init() {
-		setTemplateName("hibernate-mapping.hbm");
-    	setFilePattern("{package-name}/{class-name}.hbm.xml");
-    	setTemplatePrefix("hbm/");
+		setTemplateName("hbm/hibernate-mapping.hbm.ftl");
+    	setFilePattern("{package-name}/{class-name}.hbm.xml");    	
 	}
 
 	public HibernateMappingExporter() {

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/MetaAttributeHelper.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/MetaAttributeHelper.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/MetaAttributeHelper.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -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: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/POJOExporter.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/POJOExporter.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/POJOExporter.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -13,7 +13,7 @@
  */
 public class POJOExporter extends GenericExporter {
 
-	private static final String POJO_JAVACLASS_VM = "Pojo";
+	private static final String POJO_JAVACLASS_FTL = "pojo/Pojo.ftl";
 
     public POJOExporter(Configuration cfg, File outputdir) {
     	super(cfg, outputdir);    	
@@ -21,9 +21,8 @@
     }
     
 	protected void init() {
-		setTemplateName(POJO_JAVACLASS_VM);
-    	setFilePattern("{package-name}/{class-name}.java");
-    	setTemplatePrefix("pojo/");
+		setTemplateName(POJO_JAVACLASS_FTL);
+    	setFilePattern("{package-name}/{class-name}.java");    	
 	}
 
 	public POJOExporter() {

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/StringUtils.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/StringUtils.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/StringUtils.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1557,4 +1557,24 @@
 
         return true;
     }
+    
+    /**
+     * Strip any of the supplied string from the start of a string but
+     * do not strip more than maxStrip characters.
+     * <p>
+     * If maxStrip value is zero then no restriction is imposed.
+     * <p>
+     * @param str  the string to remove characters from
+     * @param strip  the string to remove
+     * @param max characters to strip
+     * @return the stripped string
+     */
+    public static String stripStart(String str, String strip, int maxStrip) {
+    	if (str == null) return null;
+
+    	if (maxStrip > 0 && str.length() > maxStrip)
+    		return stripStart(str.substring(0,maxStrip), strip) + str.substring(maxStrip);
+    	else
+    		return stripStart(str, strip);
+    }
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateHelper.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateHelper.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateHelper.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -18,6 +18,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hibernate.tool.Version;
 
 import freemarker.cache.ClassTemplateLoader;
 import freemarker.cache.FileTemplateLoader;
@@ -57,9 +58,8 @@
 		
 	}
 	
-    public void init(File outputDirectory, String templatePrefix, String[] templatePaths) {
+    public void init(File outputDirectory, String[] templatePaths) {
         this.outputDirectory = outputDirectory;
-        this.templatePrefix = templatePrefix;
         
         context = new SimpleHash(ObjectWrapper.BEANS_WRAPPER);
     	freeMarkerEngine = new Configuration();
@@ -148,7 +148,9 @@
     	log.trace("putInContext " + key + "=" + value);
         if(value == null) throw new IllegalStateException("value must not be null for " + key);
         Object replaced = internalPutInContext(key,value);
-        if(replaced!=null) throw new IllegalStateException(replaced + " found when setting " + key);
+        if(replaced!=null) {
+        	log.warn( "Overwriting " + replaced + " when setting " + key + " to " + value + ".");
+        }
     }
     
 	public void removeFromContext(String key, Object expected) {
@@ -239,7 +241,7 @@
     /** look up the template named templateName via the paths and print the content to the output */
     public void processTemplate(String templateName, Writer output) {
     	try {
-    		Template template = freeMarkerEngine.getTemplate(getTemplateName(templateName));
+    		Template template = freeMarkerEngine.getTemplate(templateName);
     		template.process(getContext(), output);            
         } 
         catch (IOException e) {
@@ -252,6 +254,7 @@
             throw new ExporterException("Error while processing template " + templateName, e);
         }    	
     }
+        
     
     /**
      * Check if the template exists. Tries to search with the templatePrefix first and then secondly without the template prefix.
@@ -259,7 +262,7 @@
      * @param name
      * @return
      */    
-    protected String getTemplateName(String name) {
+    /*protected String getTemplateName(String name) {
     	if(!name.endsWith(".ftl")) {
     		name = name + ".ftl";	
     	}
@@ -273,7 +276,7 @@
     	} 
     	
 		throw new ExporterException("Could not find template with name: " + name);
-    }
+    }*/
     
     public boolean templateExists(String templateName) {
     	TemplateLoader templateLoader = freeMarkerEngine.getTemplateLoader();

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateProducer.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateProducer.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/TemplateProducer.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -37,7 +37,7 @@
 			th.ensureExistence( destination );    
 	     
 			ac.addFile(destination, fileType);
-			log.info("Writing " + identifier + " to " + destination.getAbsolutePath() );
+			log.debug("Writing " + identifier + " to " + destination.getAbsolutePath() );
 			fileWriter = new FileWriter(destination);
             fileWriter.write(tempResult);			
 		} 

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Version.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Version.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Version.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,39 +0,0 @@
-package org.hibernate.tool.hbm2x;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-final public class Version {
-
-	public static final String VERSION = "3.2.0.beta6";
-	
-	private static final Version instance = new Version();
-	
-	private static Log log = LogFactory.getLog( Version.class );
-
-	static {
-		log.info( "Hibernate Tools " + VERSION );
-	}
-
-	private Version() {
-		// dont instantiate me
-	}
-	
-	public String getVersion() {
-		return VERSION;
-	}
-	
-	public static Version getDefault() {
-		return instance;
-	}
-	
-	public String toString() {
-		return getVersion();
-	}
-	
-	public static void touch() {}
-	
-	public static void main(String[] args) {
-		System.out.println(new Version());
-	}
-}

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/XMLPrettyPrinter.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/XMLPrettyPrinter.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/XMLPrettyPrinter.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -17,7 +17,6 @@
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.io.Writer;
-import java.util.Arrays;
 import java.util.Properties;
 
 import org.apache.commons.logging.Log;

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -132,6 +132,10 @@
      * Map with package class lists DocFiles keyed by package name
      */
     private Map packageEntityListDocFile = new HashMap();
+
+    public DocFolder getRootDocFolder() {
+		return rootDocFolder;
+	}
     
     /**
      * Constructor.
@@ -227,12 +231,13 @@
 
             while (tables.hasNext() ) {
                 Table table = (Table) tables.next();
+                if(table.isPhysicalTable()) { 
+                	String tableFileName = table.getName() + ".html";
 
-                String tableFileName = table.getName() + ".html";
+                	DocFile tableDocFile = new DocFile(tableFileName, schemaFolder);
 
-                DocFile tableDocFile = new DocFile(tableFileName, schemaFolder);
-
-                tableDocFiles.put(table, tableDocFile);
+                	tableDocFiles.put(table, tableDocFile);
+                }
             }
         }
     }
@@ -373,7 +378,8 @@
      * @return the DocFile.
      */
     public DocFile getTableDocFile(Table table) {
-        return (DocFile) tableDocFiles.get(table);
+        DocFile docFile = (DocFile) tableDocFiles.get(table);
+		return docFile;
     }
     
     

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocHelper.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocHelper.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocHelper.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -3,9 +3,11 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.hibernate.HibernateException;
 import org.hibernate.cfg.Configuration;
@@ -130,7 +132,11 @@
         Iterator tablesIter = cfg.getTableMappings();
         
         while (tablesIter.hasNext() ) {
-            Table table = (Table) tablesIter.next();
+        	Table table = (Table) tablesIter.next();
+        	
+        	if(!table.isPhysicalTable()) {
+        		continue; 
+        	}
             tables.add(table);
 
             StringBuffer sb = new StringBuffer();
@@ -294,7 +300,8 @@
      */
     public List getTables(String schema) {
 
-        return (List) tablesBySchema.get(schema);
+        List list = (List) tablesBySchema.get(schema);
+        return list;
     }
     
     /**

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/jtidy.properties
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/jtidy.properties	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/jtidy.properties	2006-10-11 04:01:11 UTC (rev 10566)
@@ -6,4 +6,5 @@
 clean=yes
 output-xml=yes
 input-xml=yes
-show-warnings=yes
\ No newline at end of file
+show-warnings=yes
+trim-empty-elements=yes
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -804,10 +804,13 @@
 		List propClosure = getPropertyClosureForMinimalConstructor();
 		if(propClosure.isEmpty()) return false; // minimal=default
 		if(propClosure.equals(getPropertyClosureForFullConstructor())) return false; // minimal=full
-		
 		return true;
 	}
 
+	public boolean needsFullConstructor() {
+		return !getPropertyClosureForFullConstructor().isEmpty();		
+	}
+	
 	public String getJavaTypeName(Property p, boolean useGenerics) {
 		return c2j.getJavaTypeName(p, useGenerics, this);
 	}

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/ComponentPOJOClass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/ComponentPOJOClass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/ComponentPOJOClass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -160,5 +160,8 @@
 		return null;
 	}
 
-
+   public boolean hasVersionProperty() {
+	   return false;
+   }
+	
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -18,6 +18,7 @@
 import org.hibernate.mapping.KeyValue;
 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.Subclass;
@@ -591,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() ) ) {
@@ -779,4 +781,7 @@
 		return getClass().getName() + "(" + (clazz==null?"<none>":clazz.getEntityName()) + ")";
 	}
 	
+	public boolean hasVersionProperty() {
+		return clazz.isVersioned() && clazz instanceof RootClass;
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/POJOClass.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/POJOClass.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/POJOClass.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -94,6 +94,7 @@
 	public List getPropertyClosureForSuperclassFullConstructor();
 	
 	public boolean needsMinimalConstructor();
+	public boolean needsFullConstructor();
 	public List getPropertiesForMinimalConstructor();
 	public List getPropertyClosureForMinimalConstructor();
 	public List getPropertyClosureForSuperclassMinimalConstructor();
@@ -105,4 +106,6 @@
 	
 	public Property getIdentifierProperty();
 	
+	public boolean hasVersionProperty();
+		
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/seam/SeamExporter.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/seam/SeamExporter.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/seam/SeamExporter.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -21,7 +21,7 @@
     }
 
     private void init() {
-    	setTemplatePrefix("seam/");		
+    			
 	}
 
     protected void setupContext() {

Modified: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/DefaultValueVisitor.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/DefaultValueVisitor.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/DefaultValueVisitor.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -35,7 +35,7 @@
 		this.throwException = throwException;
 	}
 
-	Object handle(Object o) {
+	protected Object handle(Object o) {
 		if (throwException) { 
 			throw new UnsupportedOperationException("accept on " + o); 
 		} 

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/EntityNameFromValueVisitor.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/EntityNameFromValueVisitor.java)

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/JavaTypeFromValueVisitor.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/JavaTypeFromValueVisitor.java)

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/AbstractTreeModel.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/AbstractTreeModel.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/AbstractTreeModel.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,158 +0,0 @@
-package org.hibernate.tool.stat; 
-
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-import javax.swing.event.EventListenerList;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-
-/**
- * Abstract class implementing the support for TreeModelEvents
- * and TreeModelListeners. The code is partly snipped from the
- * implementation of DefaultTreeModel.
- *
- * @version $Revision: 1.1.2.1 $
- **/
-
-public abstract class AbstractTreeModel implements TreeModel {
-
-    private EventListenerList listenerList = new EventListenerList();
-
-    /**
-     * Adds a listener for the TreeModelEvent posted after the tree changes.
-     *
-     * @see     #removeTreeModelListener
-     * @param   l       the listener to add
-     */
-    public void addTreeModelListener(TreeModelListener l) {
-        listenerList.add(TreeModelListener.class, l);
-    }
-
-    /**
-     * Removes a listener previously added with <B>addTreeModelListener()</B>.
-     *
-     * @see     #addTreeModelListener
-     * @param   l       the listener to remove
-     */  
-    public void removeTreeModelListener(TreeModelListener l) {
-        listenerList.remove(TreeModelListener.class, l);
-    }
-
-    /**
-      * Messaged when the user has altered the value for the item identified
-      * by <I>path</I> to <I>newValue</I>.  If <I>newValue</I> signifies
-      * a truly new value the model should post a treeNodesChanged
-      * event.
-      *
-      * @param path path to the node that the user has altered.
-      * @param newValue the new value from the TreeCellEditor.
-      */
-    public void valueForPathChanged(TreePath path, Object newValue) {
-        throw new RuntimeException("AbstractTreeModel.valueForPathChanged: you MUST override this when using a TreeCellEditor!");
-    }
-
-    /*
-     * Notify all listeners that have registered interest for
-     * notification on this event type.  The event instance 
-     * is lazily created using the parameters passed into 
-     * the fire method.
-     * @see EventListenerList
-     */
-    protected void fireTreeNodesChanged(Object source, Object[] path, 
-                                        int[] childIndices, 
-                                        Object[] children) {
-        // Guaranteed to return a non-null array
-        Object[] listeners = listenerList.getListenerList();
-        TreeModelEvent e = null;
-        // Process the listeners last to first, notifying
-        // those that are interested in this event
-        for (int i = listeners.length-2; i>=0; i-=2) {
-            if (listeners[i]==TreeModelListener.class) {
-                // Lazily create the event:
-                if (e == null)
-                    e = new TreeModelEvent(source, path, 
-                                           childIndices, children);
-                ((TreeModelListener)listeners[i+1]).treeNodesChanged(e);
-            }          
-        }
-    }
-
-    /*
-     * Notify all listeners that have registered interest for
-     * notification on this event type.  The event instance 
-     * is lazily created using the parameters passed into 
-     * the fire method.
-     * @see EventListenerList
-     */
-    protected void fireTreeNodesInserted(Object source, Object[] path, 
-                                        int[] childIndices, 
-                                        Object[] children) {
-        // Guaranteed to return a non-null array
-        Object[] listeners = listenerList.getListenerList();
-        TreeModelEvent e = null;
-        // Process the listeners last to first, notifying
-        // those that are interested in this event
-        for (int i = listeners.length-2; i>=0; i-=2) {
-            if (listeners[i]==TreeModelListener.class) {
-                // Lazily create the event:
-                if (e == null)
-                    e = new TreeModelEvent(source, path, 
-                                           childIndices, children);
-                ((TreeModelListener)listeners[i+1]).treeNodesInserted(e);
-            }          
-        }
-    }
-
-    /*
-     * Notify all listeners that have registered interest for
-     * notification on this event type.  The event instance 
-     * is lazily created using the parameters passed into 
-     * the fire method.
-     * @see EventListenerList
-     */
-    protected void fireTreeNodesRemoved(Object source, Object[] path, 
-                                        int[] childIndices, 
-                                        Object[] children) {
-        // Guaranteed to return a non-null array
-        Object[] listeners = listenerList.getListenerList();
-        TreeModelEvent e = null;
-        // Process the listeners last to first, notifying
-        // those that are interested in this event
-        for (int i = listeners.length-2; i>=0; i-=2) {
-            if (listeners[i]==TreeModelListener.class) {
-                // Lazily create the event:
-                if (e == null)
-                    e = new TreeModelEvent(source, path, 
-                                           childIndices, children);
-                ((TreeModelListener)listeners[i+1]).treeNodesRemoved(e);
-            }          
-        }
-    }
-
-    /*
-     * Notify all listeners that have registered interest for
-     * notification on this event type.  The event instance 
-     * is lazily created using the parameters passed into 
-     * the fire method.
-     * @see EventListenerList
-     */
-    protected void fireTreeStructureChanged(Object source, Object[] path, 
-                                            int[] childIndices, 
-                                            Object[] children) {
-        // Guaranteed to return a non-null array
-        Object[] listeners = listenerList.getListenerList();
-        TreeModelEvent e = null;
-        // Process the listeners last to first, notifying
-        // those that are interested in this event
-        for (int i = listeners.length-2; i>=0; i-=2) {
-            if (listeners[i]==TreeModelListener.class) {
-                // Lazily create the event:
-                if (e == null)
-                    e = new TreeModelEvent(source, path, 
-                                           childIndices, children);
-                ((TreeModelListener)listeners[i+1]).treeStructureChanged(e);
-            }          
-        }
-    }
-    
-}

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/AbstractTreeModel.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/AbstractTreeModel.java)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/BeanTableModel.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/BeanTableModel.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/BeanTableModel.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,112 +0,0 @@
-package org.hibernate.tool.stat;
-
-import java.beans.BeanDescriptor;
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-
-public class BeanTableModel extends AbstractTableModel {
-
-	protected List list;
-
-	private BeanInfo beanInfo = null;
-
-	private PropertyDescriptor[] descriptors = null;
-	
-	public BeanTableModel(List list, Class beanClass) {
-		this.list = list;
-		introspect( beanClass );
-	}
-
-	private void introspect(Class beanClass) {
-		try {
-			this.beanInfo = Introspector.getBeanInfo( beanClass,
-					Introspector.USE_ALL_BEANINFO );
-			//descriptor = beanInfo.getBeanDescriptor();
-			descriptors = beanInfo.getPropertyDescriptors();
-		}
-		catch (IntrospectionException ie) {
-			// ignore
-		}
-		
-		List v = new ArrayList(descriptors.length);
-		for (int i = 0; i < descriptors.length; i++) {
-			if(!descriptors[i].getName().equals("class")) {
-				v.add( descriptors[i] );
-			}			
-		}
-		descriptors = (PropertyDescriptor[]) v.toArray( new PropertyDescriptor[v.size()] );
-
-	}
-
-	boolean isSingle() {
-		return list.size()<=1;
-	}
-	
-	public int getRowCount() {
-		return isSingle() ? descriptors.length : list.size();
-	}
-
-	public int getColumnCount() {
-		return isSingle() ? list.size() + 1 : (descriptors != null ? descriptors.length : 0);
-	}
-
-	public Object getValueAt(int row, int col) {
-		if(isSingle()) {
-			if(col==0) {
-				return descriptors[row].getDisplayName();
-			} else {
-				return getValue(0, row);
-			}
-		} else {
-			return getValue( row, col );
-		}
-	}
-
-	private Object getValue(int row, int col) {
-		Object bean = list.get( row );
-		Object result = null;
-		try {
-			result = descriptors[col].getReadMethod().invoke( bean, null );
-		}
-		catch (InvocationTargetException ite) {
-			ite.printStackTrace();
-		}
-		catch (IllegalAccessException iae) {
-			iae.printStackTrace();
-		}
-		return result;
-	}
-
-	public String getColumnName(int col) {
-		if(isSingle()) {
-			if(col==0) {
-				return "Name";
-			} else {
-				return "Value";
-			}
-		} else {
-			return descriptors[col].getDisplayName();
-		}
-	}
-
-	public Class getColumnClass(int c) {
-		if(isSingle()) {
-			return String.class;
-		} else {
-			Class propertyType = descriptors[c].getPropertyType();
-
-			if(propertyType.isPrimitive()) {
-				return String.class; // to avoid jtable complain about null table renderer.
-			} else {
-				return propertyType;
-			}
-		}
-	}
-}
\ No newline at end of file

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/BeanTableModel.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/BeanTableModel.java)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsBrowser.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsBrowser.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsBrowser.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,110 +0,0 @@
-package org.hibernate.tool.stat;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JScrollPane;
-import javax.swing.JSplitPane;
-import javax.swing.JTable;
-import javax.swing.JTree;
-import javax.swing.ToolTipManager;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.table.TableCellRenderer;
-
-import org.hibernate.stat.Statistics;
-
-/**
- * Very rudimentary statistics browser.
- * 
- * Usage:
- * new StatisticsBrowser().showStatistics(getSessions().getStatistics(), shouldBlock);
- * 
- * @author max
- *
- */
-public class StatisticsBrowser {
-	
-	/**
-	 * 
-	 * @param stats a Statistics instance obtained from a SessionFactory
-	 * @param shouldBlock decides if the ui will be modal or not.
-	 */
-	public void showStatistics(Statistics stats, boolean shouldBlock) {
-		
-		JDialog main = new JDialog((JFrame)null, "Statistics browser");
-		
-		main.getContentPane().setLayout(new BorderLayout());
-		
-		final StatisticsTreeModel statisticsTreeModel = new StatisticsTreeModel(stats);
-		JTree tree = new JTree(statisticsTreeModel);
-		tree.setCellRenderer( new StatisticsCellRenderer() );
-		ToolTipManager.sharedInstance().registerComponent(tree);
-		
-		JScrollPane treePane = new JScrollPane(tree);
-		
-		final JTable table = new JTable() {
-			public TableCellRenderer getDefaultRenderer(Class columnClass) {
-				TableCellRenderer defaultRenderer = super.getDefaultRenderer( columnClass );
-				
-				if(defaultRenderer==null) {
-					return super.getDefaultRenderer( Object.class );
-				} else {
-					return defaultRenderer;
-				}
-			}
-		};
-		
-		JScrollPane tablePane = new JScrollPane(table);
-		tablePane.getViewport().setBackground( table.getBackground() );
-		final BeanTableModel beanTableModel = new BeanTableModel(Collections.EMPTY_LIST, Object.class);
-		table.setModel( beanTableModel );
-		
-		JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePane, tablePane);
-		pane.setContinuousLayout( true );
-		
-		main.getContentPane().add(pane, BorderLayout.CENTER);
-		
-		tree.addTreeSelectionListener( new TreeSelectionListener() {
-		
-			public void valueChanged(TreeSelectionEvent e) {
-				Object lastPathComponent = e.getPath().getLastPathComponent();
-				List l = new ArrayList();
-				if(statisticsTreeModel.isContainer( lastPathComponent )) {
-					int childCount = statisticsTreeModel.getChildCount( lastPathComponent );
-					
-					Class cl = Object.class;
-					for (int i = 0; i < childCount; i++) {
-						Object v = statisticsTreeModel.getChild( lastPathComponent, i );
-						if(v!=null) cl = v.getClass();
-						l.add(v);
-					}
-					table.setModel( new BeanTableModel(l, cl) );	
-				} else {
-					l.add( lastPathComponent );
-					table.setModel( new BeanTableModel(l, lastPathComponent.getClass()) );
-				}
-				
-				//table.doLayout();
-				
-			}
-		
-		} );
-		
-		
-		main.getContentPane().setSize(new Dimension(640,480));
-		main.pack();
-		main.setModal(shouldBlock);
-		main.setVisible(true);
-	}
-	
-	
-	
-	
-
-}

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsBrowser.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsBrowser.java)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsCellRenderer.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsCellRenderer.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsCellRenderer.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,61 +0,0 @@
-package org.hibernate.tool.stat;
-
-import java.awt.Component;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import javax.swing.JLabel;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import org.hibernate.stat.CategorizedStatistics;
-import org.hibernate.stat.CollectionStatistics;
-import org.hibernate.stat.EntityStatistics;
-import org.hibernate.stat.QueryStatistics;
-import org.hibernate.stat.Statistics;
-
-public class StatisticsCellRenderer extends DefaultTreeCellRenderer {
-
-	SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
-	
-	public Component getTreeCellRendererComponent(JTree tree, Object value,
-			boolean selected, boolean expanded, boolean leaf, int row,
-			boolean hasFocus) {
-		
-		JLabel treeCellRendererComponent = (JLabel) super.getTreeCellRendererComponent( tree, value, selected, expanded, leaf, row, hasFocus );
-		
-		String text = treeCellRendererComponent.getText();
-		String tooltip = null;
-		if(value instanceof Statistics) {
-			Statistics stats = (Statistics) value;
-			text = "Statistics " + formatter.format( new Date(stats.getStartTime()) );
-			tooltip = stats.toString();
-		}
-		
-		if(value instanceof CategorizedStatistics) {
-			CategorizedStatistics stats = (CategorizedStatistics) value;
-			text = stats.getCategoryName();
-			
-		}
-		if(value instanceof EntityStatistics) {
-			EntityStatistics stats = (EntityStatistics) value;
-			
-		}
-		
-		if(value instanceof CollectionStatistics) {
-			CollectionStatistics stats = (CollectionStatistics) value;
-			
-		}
-		
-		if(value instanceof QueryStatistics) {
-			QueryStatistics stats = (QueryStatistics) value;
-		
-		}
-		
-		treeCellRendererComponent.setText( text );
-		treeCellRendererComponent.setToolTipText( tooltip );
-		return treeCellRendererComponent;
-	}
-
-	
-}

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsCellRenderer.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsCellRenderer.java)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsTreeModel.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsTreeModel.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsTreeModel.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,99 +0,0 @@
-package org.hibernate.tool.stat;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.hibernate.stat.SecondLevelCacheStatistics;
-import org.hibernate.stat.Statistics;
-import org.hibernate.util.IdentityMap;
-
-public class StatisticsTreeModel extends AbstractTreeModel {
-
-	private final Statistics stats;
-
-	String queries = "Queries";
-	String entities = "Entities";
-	String collections = "Collections";
-	String secondlevelcache = "Cache";
-	
-	Map im = IdentityMap.instantiate( 10 ); 
-	
-	public StatisticsTreeModel(Statistics stats) {
-		this.stats = stats;
-	}
-
-	public Object getChild(Object parent, int index) {
-		if(parent==stats) {
-			switch(index) {
-			case 0: return entities;
-			case 1: return collections;
-			case 2:	return queries;		
-			case 3: return secondlevelcache;
-			}
-		} else if(parent==entities) {
-			return stats.getEntityStatistics(stats.getEntityNames()[index]);
-		} else if(parent==collections) {
-			return stats.getCollectionStatistics(stats.getCollectionRoleNames()[index]);
-		} else if(parent==queries) {
-			return stats.getQueryStatistics(stats.getQueries()[index]);
-		} else if(parent==secondlevelcache) {
-			return stats.getSecondLevelCacheStatistics( stats.getSecondLevelCacheRegionNames()[index]);
-		} else if(parent instanceof SecondLevelCacheStatistics) {
-			SecondLevelCacheStatistics stats = (SecondLevelCacheStatistics) parent;			
-			return stats.getEntries();
-		}
-		return null;
-	}
-
-	public int getChildCount(Object parent) {
-		if(parent==stats) {
-			return 4;
-		} else if(parent==entities) {
-			return stats.getEntityNames().length;
-		} else if(parent==collections) {
-			return stats.getCollectionRoleNames().length;
-		} else if(parent==queries) {
-			return stats.getQueries().length;
-		} else if(parent==secondlevelcache) {
-			return stats.getSecondLevelCacheRegionNames().length;
-		} else if(parent instanceof SecondLevelCacheStatistics) {
-			/*SecondLevelCacheStatistics stats = (SecondLevelCacheStatistics) parent;
-			return stats.getEntries().size();*/
-		}
-		return 0;
-	}
-
-	public int getIndexOfChild(Object parent, Object child) {
-		throw new IllegalAccessError();
-		//return 0;
-	}
-
-	public Object getRoot() {
-		return stats;
-	}
-
-	public boolean isLeaf(Object node) {
-		return false;
-	}
-	
-	public boolean isQueries(Object o) {
-		return o==queries; // hack
-	}
-	
-	public boolean isCollections(Object o) {
-		return o==collections; // hack
-	}
-	
-	public boolean isEntities(Object o) {
-		return o==entities; // hack
-	}
-
-	public boolean isCache(Object o) {
-		return o==secondlevelcache;
-	}
-	
-	public boolean isContainer(Object o) {
-		return isEntities( o ) || isQueries( o ) || isCollections( o ) || isCache( o );
-	}
-	
-}
\ No newline at end of file

Copied: branches/Lucene_Integration/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsTreeModel.java (from rev 10565, trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsTreeModel.java)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/dao/daohome.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/dao/daohome.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/dao/daohome.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -54,6 +54,7 @@
         }
     }
     
+<#if clazz.identifierProperty?has_content>    
     public ${declarationName} findById( ${pojo.getJavaTypeName(clazz.identifierProperty, jdk5)} id) {
         log.debug("getting ${declarationName} instance with id: " + id);
         try {
@@ -66,6 +67,7 @@
             throw re;
         }
     }
+</#if>
 <#else>    
     private final ${pojo.importType("org.hibernate.SessionFactory")} sessionFactory = getSessionFactory();
     
@@ -141,6 +143,7 @@
         }
     }
     
+<#if clazz.identifierProperty?has_content>
     public ${declarationName} findById( ${c2j.getJavaTypeName(clazz.identifierProperty, jdk5)} id) {
         log.debug("getting ${declarationName} instance with id: " + id);
         try {
@@ -159,6 +162,7 @@
             throw re;
         }
     }
+</#if>
     
 <#if clazz.hasNaturalId()>
     public ${declarationName} findByNaturalId(${c2j.asNaturalIdParameterList(clazz)}) {
@@ -220,9 +224,9 @@
         }
     } 
 <#foreach queryName in cfg.namedQueries.keySet()>
-<#if queryName.startsWith(clazz.entityName)>
+<#if queryName.startsWith(clazz.entityName + ".")>
 <#assign methname = c2j.unqualify(queryName)>
-<#assign params = cfg.namedQueries.get(queryName).parameterTypes><#assign argList = c2j.asFinderArgumentList(params, clazz)>
+<#assign params = cfg.namedQueries.get(queryName).parameterTypes><#assign argList = c2j.asFinderArgumentList(params, pojo)>
 <#if jdk5 && methname.startsWith("find")>
     public ${pojo.importType("java.util.List")}<${declarationName}> ${methname}(${argList}) {
 <#elseif methname.startsWith("count")>

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/entities/summary.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/entities/summary.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/entities/summary.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -14,6 +14,15 @@
 
 <H1>Hibernate Mapping Documentation</H1>
 
+<#if graphsGenerated>
+<p>
+ <img src="entitygraph.png" usemap="#entitygraph"/>
+  <map name="entitygraph">
+  ${entitygrapharea}
+ </map>
+</p>
+</#if>
+
 <H2>List of Packages</H2>
 
 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/index.html
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/index.html	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/index.html	2006-10-11 04:01:11 UTC (rev 10566)
@@ -12,7 +12,7 @@
 
 <FRAMESET rows="50px,80%">
 	<FRAME src="header.html" name="headerFrame" title="Header">
-	<FRAME src="tables/index.html" name="mainFrame" title="Main">
+	<FRAME src="entities/index.html" name="mainFrame" title="Main">
 	<NOFRAMES>
 		<H2>Frame Alert</H2>
 		This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web browser.

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/tables/summary.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/tables/summary.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/doc/tables/summary.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -14,6 +14,15 @@
 
 <H1>Hibernate Mapping Documentation</H1>
 
+<#if graphsGenerated>
+<p>
+ <img src="tablegraph.png" usemap="#tablegraph"/>
+ <map name="tablegraph">
+  ${tablegrapharea}
+ </map>
+</p>
+</#if>
+
 <H2>List of Tables by Schema</H2>
 
 <#foreach schema in dochelper.tablesBySchema.keySet()>
@@ -26,7 +35,7 @@
 		</TR>
 	</THEAD>
 	<TBODY>
-<#foreach table in dochelper.tablesBySchema.get(schema)>
+<#foreach table in dochelper.getTables(schema)>
 		<TR>
 			<TD>
 				<A HREF='${docFileManager.getRef(docFile, docFileManager.getTableDocFile(table))}' TARGET="generalFrame">

Copied: branches/Lucene_Integration/HibernateExt/tools/src/templates/dot (from rev 10565, trunk/HibernateExt/tools/src/templates/dot)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,75 +0,0 @@
-digraph EntityGraph {
-  compound=true;
-    bgcolor="white"; 
-    fontcolor="black"; fontname="Helvetica"; fontsize="10.0"; 
-    ranksep="equally"; 
-    label="Entity Graph"; 
-    URL="http://tools.hibernate.org";
-  edge [
-        color="lightgrey", 
-        fontcolor="black", 
-        fontname="Helvetica", 
-        fontsize="8.0",         
-        labelangle=-25.0, 
-        labeldistance=1.5
-        ];
-  node [
-       fontcolor="black",
-       fontname="Helvetica", 
-       fontsize="10.0", 
-       shape=record, 
-       fillcolor="#D4E5FE", 
-       style="solid,filled"];
-
-<#foreach entity in cfg.classMappings> 
-  /* Node ${entity.entityName} */
-  <@nodeName entity.entityName/> [ label = "<@propertyLabels name=entity.entityName properties=entity.propertyIterator/>", URL="${entity.entityName?replace(".","/")}.html" ]
-  /* Subclass edges for ${entity.entityName} */
-  <#foreach subclass in entity.getDirectSubclasses()>
-     <@nodeName subclass.entityName/> -> <@nodeName entity.entityName/>  [ weight="10", arrowhead="onormal"  ]
-  </#foreach>
-  
-  <@propertyEdges root=entity.entityName?replace(".","_dot_") properties=entity.propertyIterator/>     
-</#foreach>
-
-}
-
-<#macro nodeName name>${name?replace(".","_dot_")}</#macro>
-
-<#macro propertyLabels name properties>
-<@compress single_line=true>
-             { 
-                ${name?replace(".","\\.")}|
-                <#foreach p in properties>
-                 <#if p.value.isSimpleValue()> 
-                   ${p.name}\l
-                 </#if>
-                </#foreach>
-              }</@compress></#macro>
-
-<#macro dumpComponent compProperty>
-      <#assign component=compProperty.value>
-      /* Node component ${component} */
-      ${c2h.getHibernateTypeName(compProperty)?replace(".","_dot_")} [ 
-        label = "<@propertyLabels name=component.componentClassName properties=component.propertyIterator/>"
-           ]
-      <@propertyEdges root=component.componentClassName?replace(".","_dot_") properties=component.propertyIterator/>   
-</#macro>
-
-<#macro propertyEdges root properties>
-  /* Property edges/nodes for ${root} */
-  <#foreach property in properties>
-     <#if c2h.getHibernateTypeName(property)?exists>
-     ${root} -> ${c2h.getHibernateTypeName(property)?replace(".","_dot_")} [ 
-        label="${property.name}" 
-        <#if c2j.isComponent(property)>
-        arrowtail="diamond"
-        </#if>
-        ]
-     </#if>
-     <#if c2j.isComponent(property)>
-     <@dumpComponent property/>
-     </#if>
-     
-  </#foreach>
-</#macro>
\ No newline at end of file

Copied: branches/Lucene_Integration/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl (from rev 10565, trunk/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/templates/dot/tablegraph.dot.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/dot/tablegraph.dot.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/dot/tablegraph.dot.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,57 +0,0 @@
-digraph TableGraph {
-  compound=true;
-    bgcolor="white"; 
-    fontcolor="black"; fontname="Helvetica"; fontsize="10.0"; 
-    ranksep="equally"; 
-    label="Table Graph"; 
-    URL="http://tools.hibernate.org";
-  edge [
-        color="lightgrey", 
-        fontcolor="black", 
-        fontname="Helvetica", 
-        fontsize="8.0",         
-        labelangle=-25.0, 
-        labeldistance=1.5
-        headport=nw,
-        tailport=se
-        ];
-  node [
-       fontcolor="black",
-       fontname="Helvetica", 
-       fontsize="10.0", 
-       shape=record, 
-       fillcolor="yellow", 
-       style="solid,filled"];
-
-/* TODO: multi schema tables */
-<#foreach table in cfg.getTableMappings()> 
-  <#if table.isPhysicalTable()>
-  /* Node ${table.name} */
-  <@nodeName table/> [ label = "<@columnLabels name=table.name columns=table.columnIterator/>" ]  
-  
-  <@propertyEdges root=table.name?replace(".","_dot_") foreignKeys=table.foreignKeyIterator/>     
-  </#if>
-</#foreach>
-
-}
-
-<#macro nodeName table>${table.name?replace(".","_dot_")}</#macro>
-
-<#macro columnLabels name columns>
-<@compress single_line=true>
-             { 
-                ${name?replace(".","\\.")}|
-                <#foreach p in columns>
-                   <${p.name}>${p.name}\l
-                   <#if p_has_next>|</#if>
-                </#foreach>
-              }</@compress></#macro>
-
-<#macro propertyEdges root foreignKeys>
-  /* edges/nodes for ${root} */
-  <#foreach fk in foreignKeys>
-     ${root} -> <@nodeName fk.referencedTable/> [ 
-        label="${fk.name}" 
-        ]
-  </#foreach>
-</#macro>
\ No newline at end of file

Copied: branches/Lucene_Integration/HibernateExt/tools/src/templates/dot/tablegraph.dot.ftl (from rev 10565, trunk/HibernateExt/tools/src/templates/dot/tablegraph.dot.ftl)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/array.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/array.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/array.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -9,6 +9,8 @@
 <#assign toManyClass = value.getElement().getType().getAssociatedEntityName()>
 </#if>
 <array name="${property.name}" cascade="${property.cascade}" 
+ <#assign metaattributable=property>
+ <#include "meta.hbm.ftl">
 <#if c2h.hasFetchMode(property)> fetch="${fetch}"</#if>>
     <key> 
        <#foreach column in dependentValue.columnIterator>

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,6 +2,9 @@
 		name="${property.name}"
         inverse="${property.value.inverse?string}"
 	>
+	 <#assign metaattributable=property>
+	 <#include "meta.hbm.ftl">
+	
  		<key> 
         <#foreach column in property.value.key.columnIterator>
           <#include "column.hbm.ftl">

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/component.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/component.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/component.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,8 @@
 <component 
     name="${property.name}"
     class="${property.value.componentClassName}">
+    <#assign metaattributable=property>
+	<#include "meta.hbm.ftl">
+    
 <!-- TODO -->    
 </component>
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/id.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/id.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/id.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -27,6 +27,9 @@
         access="${property.propertyAccessorName}"
  </#if>
     >
+    <#assign metaattributable=property>
+	<#include "meta.hbm.ftl">
+    
  <#foreach column in property.columnIterator>
 	    <#include "pkcolumn.hbm.ftl">
  </#foreach>

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/list.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/list.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/list.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -2,6 +2,9 @@
 		name="${property.name}"
         inverse="${property.value.inverse?string}"
 		>
+		<#assign metaattributable=property>
+		<#include "meta.hbm.ftl">
+		
 		<key> 
            <#foreach column in property.value.key.columnIterator>
               <#include "column.hbm.ftl">

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/many-to-one.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/many-to-one.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/many-to-one.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -25,11 +25,11 @@
 <#if formula>
         formula="${formula.text}"
 </#if>
-    />
-<#else>
+</#if>
     >
+    <#assign metaattributable=property>
+	<#include "meta.hbm.ftl">    
 <#foreach column in property.columnIterator>
         <#include "column.hbm.ftl">
 </#foreach>	
    </many-to-one>
-</#if>

Copied: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/meta.hbm.ftl (from rev 10565, trunk/HibernateExt/tools/src/templates/hbm/meta.hbm.ftl)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -6,7 +6,9 @@
 <#if clazz.superclass?exists>
     extends="${clazz.getSuperclass().className}"
 </#if>
+<#if c2h.needsTable(clazz)>
     table="${clazz.table.quotedName}"
+</#if>
 <#if clazz.table.schema?exists>
     schema="${clazz.table.quotedSchema}"
 </#if>
@@ -25,7 +27,7 @@
 <#if clazz.hasSelectBeforeUpdate()>
     select-before-update="true"
 </#if>
-<#if !c2h.getClassName(clazz).equals(clazz.discriminatorValue)>
+<#if c2h.needsDiscriminator(clazz)>
     discriminator-value="${clazz.discriminatorValue}"
 </#if>
 <#if clazz.isExplicitPolymorphism()>
@@ -51,26 +53,45 @@
 <#if clazz.table.subselect>
     subselect="${clazz.table.getSubselect()}"
 </#if>
-<#if clazz.getEntityPersisterClass()?exists>
+<#if c2h.hasCustomEntityPersister(clazz)>
     persister="${clazz.getEntityPersisterClass().name}"
 </#if>
 <#if clazz.table.rowId?exists>
     rowid="${clazz.table.rowId}"
 </#if>>
+<#assign metaattributable=clazz/>
+<#include "meta.hbm.ftl"/>
+
 <#if clazz.table.comment?exists>
  <comment>${clazz.table.comment}</comment>
 </#if>
 <#-- TODO: move this to id.hbm.ftl -->
-<#if clazz.hasIdentifierProperty()>
-<#assign property=clazz.getIdentifierProperty()/>
-<#include "id.hbm.ftl"/>
-<#elseif clazz.hasEmbeddedIdentifier()>
-<#assign embeddedid=clazz.key/>
-<#include "id.hbm.ftl"/>
+<#if !c2h.isSubclass(clazz)>
+ <#if clazz.hasIdentifierProperty()>
+ <#assign property=clazz.getIdentifierProperty()/>
+ <#include "id.hbm.ftl"/>
+ <#elseif clazz.hasEmbeddedIdentifier()>
+ <#assign embeddedid=clazz.key/>
+ <#include "id.hbm.ftl"/>
+ </#if>
+<#elseif c2h.isJoinedSubclass(clazz)>
+ <key> 
+       <#foreach column in clazz.key.columnIterator>
+                <#include "column.hbm.ftl">
+       </#foreach>
+ </key>
 </#if>
 
+<#-- version has to be done explicitly since Annotation's does not list version first -->
+<#if pojo.hasVersionProperty()>
+<#assign property=clazz.getVersion()/>
+<#include "${c2h.getTag(property)}.hbm.ftl"/>
+</#if>
+
 <#foreach property in clazz.getUnjoinedPropertyIterator()>
+<#if c2h.getTag(property)!="version" && c2h.getTag(property)!="timestamp">
 <#include "${c2h.getTag(property)}.hbm.ftl"/>
+</#if>
 </#foreach>
 
-</${c2h.getTag(clazz)}>
\ No newline at end of file
+</${c2h.getTag(clazz)}>

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,5 +1,7 @@
 <#assign value = property.value><#assign table = value.getElement().getTable().getName()><#assign dependentValue = value.getKey()>
 <primitive-array name="${property.name}" table="${table}">
+ <#assign metaattributable=property>
+ <#include "meta.hbm.ftl">
  <key>
        <#foreach column in dependentValue.getColumnIterator()>
         <#include "column.hbm.ftl">

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/property.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/property.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/property.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -21,10 +21,12 @@
 <#if formula?has_content>
         formula="${formula.text}"
 </#if>
-    />
-<#else>
+</#if>
     >
+  <#assign metaattributable=property>
+  <#include "meta.hbm.ftl">
   <#foreach column in property.columnIterator>
         <#include "column.hbm.ftl">
-  </#foreach>	</property>
-</#if>
+  </#foreach>	
+  </property>
+

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/set.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/set.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/set.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,7 +1,12 @@
 	<set
 		name="${property.name}"
 		inverse="${property.value.inverse?string}"
+		<#if !c2h.isOneToMany(property)>
+		table="${property.value.collectionTable.name}"
+		</#if>
 		>
+		<#assign metaattributable=property>
+		<#include "meta.hbm.ftl">
 		<key> 
         <#foreach column in property.value.key.columnIterator>
           <#include "column.hbm.ftl">
@@ -16,7 +21,7 @@
 			/>			
 <#elseif c2h.isManyToMany(property)>
         <many-to-many 
-			 entity-name="$c2h.getClassName($property.getValue().getElement())"> <#-- lookup needed classname -->
+			 entity-name="${property.getValue().getElement().getReferencedEntityName()}"> <#-- lookup needed classname -->
 <#foreach column in property.getValue().getElement().columnIterator>
     <#include "column.hbm.ftl">
 </#foreach>            

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/timestamp.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/timestamp.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/timestamp.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,7 +1,7 @@
     <timestamp
         name="${property.name}"
 <#if !property.basicPropertyAccessor>        access="${property.propertyAccessorName}"
-</#if><#foreach column in property.columnIterator> <#-- always only one column, but no direct access method.
--->        column="${column.quotedName}" 
+</#if><#foreach column in property.columnIterator> <#-- always only one column, but no direct access method.-->
+        column="${column.quotedName}" 
 </#foreach>    />
 

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/version.hbm.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/version.hbm.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/hbm/version.hbm.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -3,5 +3,8 @@
         type="${property.value.typeName}"
 <#if !property.basicPropertyAccessor>        access="${property.propertyAccessorName}"
 </#if>    >
-<#foreach column in property.columnIterator>        <#include "column.hbm.ftl"></#foreach>	</version>
+<#foreach column in property.columnIterator> 
+       <#include "column.hbm.ftl">
+</#foreach>
+	</version>
 

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/pojo/PojoConstructors.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/pojo/PojoConstructors.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/pojo/PojoConstructors.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -14,6 +14,7 @@
 </#foreach>
     }
 </#if>    
+<#if pojo.needsFullConstructor()>
     /** full constructor */
     public ${pojo.getDeclarationName()}(${c2j.asParameterList(pojo.getPropertyClosureForFullConstructor(), jdk5, pojo)}) {
 <#if pojo.isSubclass() && !pojo.getPropertyClosureForSuperclassFullConstructor().isEmpty()>
@@ -23,4 +24,4 @@
        this.${field.name} = ${field.name};
 </#foreach>
     }
-    
+</#if>    

Modified: branches/Lucene_Integration/HibernateExt/tools/src/templates/seam/selector.java.ftl
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/templates/seam/selector.java.ftl	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/templates/seam/selector.java.ftl	2006-10-11 04:01:11 UTC (rev 10566)
@@ -23,7 +23,7 @@
    @${pojo.importType("javax.interceptor.Interceptors")}(${pojo.importType("org.jboss.seam.ejb.SeamInterceptor")}.class)
    public static class Default${pojo.shortName}Selector implements ${pojo.shortName}Selector {
    
-      @${pojo.importType("org.jboss.seam.annotations.In")}
+      @${pojo.importType("org.jboss.seam.annotations.In")}(create=true)
       private transient ${pojo.importType("java.util.ResourceBundle")} resourceBundle;
     
       @${pojo.importType("org.jboss.seam.annotations.In")}(create=true)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -43,13 +43,12 @@
 	protected void tearDown() throws Exception {
 		
 		if (getOutputDir()!=null) TestHelper.deleteDir(getOutputDir());
-		//assertEquals("Method not found errors during template processing:\n " + HibernateUberspect.getMethodErrors(),0,HibernateUberspect.getMethodNotFoundCount());
 		
 		assertNoTables();
 	}
 
 	
-	protected void assertFileAndExists(File file) {
+	static protected void assertFileAndExists(File file) {
 		assertTrue(file + " does not exist", file.exists() );
 		assertTrue(file + " not a file", file.isFile() );		
 		assertTrue(file + " does not have any contents", file.length()>0);
@@ -115,6 +114,24 @@
 	public boolean appliesTo(Dialect dialect) {
 		return true;
 	}
+
+	/**
+	 * @return
+	 */
+	protected String getBaseForMappings() {
+		return "org/hibernate/tool/";
+	}
+
+
+	protected void addMappings(String[] files, Configuration cfg) {
+		for (int i=0; i<files.length; i++) {						
+			if ( !files[i].startsWith("net/") ) {
+				files[i] = getBaseForMappings() + files[i];
+			}
+			//System.out.println("bc in " + this.getClass() + " " + getBaseForMappings() + " " + files[i]);
+			cfg.addResource( files[i], this.getClass().getClassLoader() );
+		}
+	}
 	
 }
 

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -44,14 +44,9 @@
 			cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
 		}
 		
-		for (int i=0; i<files.length; i++) {						
-			if ( !files[i].startsWith("net/") ) {
-				files[i] = getBaseForMappings() + files[i];
-			}
-			//System.out.println("bc in " + this.getClass() + " " + getBaseForMappings() + " " + files[i]);
-			getCfg().addResource( files[i], this.getClass().getClassLoader() );
-		}
-		
+		Configuration cfg2 = getCfg();
+		addMappings( files, cfg2 );
+				
 		/*if ( getCacheConcurrencyStrategy()!=null ) {
 			
 			Iterator iter = cfg.getClassMappings();
@@ -87,16 +82,9 @@
 		}*/
 		
 		setDialect( Dialect.getDialect() );
-		getCfg().buildMappings();
+		cfg2.buildMappings();
 	}
 
-	/**
-	 * @return
-	 */
-	protected String getBaseForMappings() {
-		return "org/hibernate/tool/";
-	}
-
 	public String getCacheConcurrencyStrategy() {
 		return "nonstrict-read-write";
 	}
@@ -195,4 +183,8 @@
 	public Configuration getConfiguration() {
 		return getCfg();
 	}
+	
+	protected void buildSessionFactory() {
+		sessions = getCfg().buildSessionFactory();
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -70,8 +70,24 @@
 		
 		assertTrue(ejb3.exists());
 		assertEquals(null, TestHelper.findFirstString("drop", ejb3));
+		
+		assertTrue(getLog().indexOf("<ejb3configuration> is deprecated")>0);
+		
 	}
 	
+	public void testJPABogusPUnit() {
+		try {
+			executeTarget("jpa-bogusunit");
+			fail("Bogus unit accepted");
+		} catch(BuildException be) {
+			// should happen
+		}
+	}
+	
+	public void testJPAPUnit() {
+		executeTarget("jpa-punit");		
+	}
+	
 	public void testHbm2JavaConfiguration() {
 		executeTarget("testanthbm2java");
 	}
@@ -161,6 +177,15 @@
 		assertTrue(new File(baseDir, "queryresult.txt").exists());
 		
 	}
+	
+	public void testNoConfig() {
+		try {
+			executeTarget("noconfig-shoulderror");
+		} catch(BuildException e) {
+			assertTrue(e.getMessage().indexOf("No configuration specified")>=0);
+		}
+		
+	}
 	public static Test suite() {
 		return new TestSuite(HibernateToolTest.class);
 	}

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/ant/SeamAntTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/ant/SeamAntTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/ant/SeamAntTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -117,10 +117,5 @@
 		assertNotNull(document);
         return document;
     }
-	
-	protected void assertFileAndExists(File file) {
-		assertTrue(file + " does not exist", file.exists() );
-		assertTrue(file + " not a file", file.isFile() );		
-		assertTrue(file + " does not have any contents", file.length()>0);
-	}
+		
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Constructors.hbm.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Constructors.hbm.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Constructors.hbm.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -59,5 +59,13 @@
 		<version name="aVersion" type="long"/>
     	<property name="name" type="string"/>      
     </class>
+  
+    <!-- HBX-584 -->  
+    <class name="SingleFieldClass"> 
+     <id name="id" type="string"> 
+      <generator class="native"/> 
+     </id> 
+    </class> 
+  
     
 </hibernate-mapping>

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,6 +1,7 @@
 package org.hibernate.tool.hbm2x;
 
 import java.io.File;
+import java.util.Properties;
 
 import org.hibernate.tool.NonReflectiveTestCase;
 
@@ -17,7 +18,8 @@
 				"Order.hbm.xml",
 				"LineItem.hbm.xml",
 				"Product.hbm.xml",
-				"HelloWorld.hbm.xml"
+				"HelloWorld.hbm.xml",
+				"UnionSubclass.hbm.xml"
 		};
 	}
 	
@@ -27,9 +29,15 @@
 	protected void setUp() throws Exception {
 		super.setUp();
 		DocExporter exporter = new DocExporter(getCfg(), getOutputDir() );
+		Properties properties = new Properties();
+		properties.put("dot.executable", System.getProperties().getProperty("dot.executable","dot.exe"));
+		exporter.setProperties( properties );
 		exporter.start();
 	}
 	
+	protected void tearDown() throws Exception {
+		//super.tearDown();
+	}
     public void testExporter() {
     	
     	assertFileAndExists(new File(getOutputDir(), "header.html") );
@@ -40,8 +48,19 @@
     	
     	assertFileAndExists(new File(getOutputDir(), "tables/PUBLIC/summary.html") );
     	assertFileAndExists(new File(getOutputDir(), "tables/PUBLIC/Customer.html") );
+    	assertFalse(new File(getOutputDir(), "tables/PUBLIC/UPerson.html").exists() );
+    	assertFileAndExists(new File(getOutputDir(), "tables/PUBLIC/CROWN_USERS.html") );
     	
     	assertFileAndExists(new File(getOutputDir(), "entities/org/hibernate/tool/hbm2x/Customer.html") );
+    	assertTrue(new File(getOutputDir(), "entities/org/hibernate/tool/hbm2x/UPerson.html").exists() );
+    	assertFileAndExists(new File(getOutputDir(), "entities/org/hibernate/tool/hbm2x/UUser.html") );
+    	
+    	assertFileAndExists(new File(getOutputDir(), "entities/entitygraph.dot"));
+    	assertFileAndExists(new File(getOutputDir(), "entities/entitygraph.png"));
+    	
+    	assertFileAndExists(new File(getOutputDir(), "tables/tablegraph.dot"));
+    	assertFileAndExists(new File(getOutputDir(), "tables/tablegraph.png"));
+    	
 				
 	}
     

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenericExporterTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenericExporterTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenericExporterTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -11,6 +11,7 @@
 import java.util.Properties;
 
 import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.Version;
 
 /**
  * @author max
@@ -32,7 +33,7 @@
 		GenericExporter ge = new GenericExporter();
 		ge.setConfiguration(getCfg());
 		ge.setOutputDirectory(getOutputDir());
-		ge.setTemplateName("generictemplates/pojo/generic-test");
+		ge.setTemplateName("generictemplates/pojo/generic-test.ftl");
 		ge.setFilePattern("generictest.txt");
 		ge.start();
 
@@ -64,7 +65,7 @@
 		GenericExporter ge = new GenericExporter();
 		ge.setConfiguration(getCfg());
 		ge.setOutputDirectory(getOutputDir());
-		ge.setTemplateName("generictemplates/pojo/generic-class");
+		ge.setTemplateName("generictemplates/pojo/generic-class.ftl");
 		ge.setFilePattern("generic{class-name}.txt");
 		ge.start();
 
@@ -80,7 +81,7 @@
 		GenericExporter ge = new GenericExporter();
 		ge.setConfiguration(getCfg());
 		ge.setOutputDirectory(getOutputDir());
-		ge.setTemplateName("generictemplates/pojo/generic-class");
+		ge.setTemplateName("generictemplates/pojo/generic-class.ftl");
 		ge.setFilePattern("{package-name}/generic{class-name}.txt");
 		ge.start();
 
@@ -109,7 +110,7 @@
 		p.setProperty("hibernatetool.booleanProperty", "true");
 		p.setProperty("hibernatetool.myTool.toolclass", "org.hibernate.tool.hbm2x.Cfg2JavaTool");
 		ge.setProperties(p);
-		ge.setTemplateName("generictemplates/pojo/generic-class");
+		ge.setTemplateName("generictemplates/pojo/generic-class.ftl");
 		ge.setFilePattern("{package-name}/generic{class-name}.txt");
 		ge.start();		
 		
@@ -122,17 +123,6 @@
 		assertEquals(generated.getProperty("myTool.value"), "value");
 	}
 	
-	public void testGenericClassExporter() {
-		GenericExporter ge = new GenericExporter();
-		ge.setConfiguration(getCfg());
-		ge.setOutputDirectory(getOutputDir());
-		ge.setProperties(new Properties());		
-		ge.setExporterClassName("org.hibernate.tool.hbm2x.POJOExporter");
-		
-		ge.start();
-		
-	}
-	
 	protected String getBaseForMappings() {
 		return "org/hibernate/tool/hbm2x/";
 	}

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2DaoTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2DaoTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2DaoTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -56,6 +56,11 @@
         
 	}
 
+	public void testNamedQueries() {
+		
+		assertTrue(findFirstString("findByNameAndAddress",new File(getOutputDir(), "org/hibernate/tool/hbm2x/AuthorHome.java") ).trim().startsWith( "public List" ) );
+	}
+	
 	protected String getBaseForMappings() {
 		return "org/hibernate/tool/hbm2x/";
 	}

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaConstructorTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaConstructorTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaConstructorTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -108,6 +108,12 @@
 		
 	}
 
+	public void testSingleFieldLogic() {
+		
+		
+	}
+	
+	
 	public void testMinimal() {
 		POJOClass bp = new EntityPOJOClass(getCfg().getClassMapping("BrandProduct"), new Cfg2JavaTool());
 		

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -9,9 +9,12 @@
 		TestSuite suite = new TestSuite( "Test for org.hibernate.tool.hbm2x" );
 		//$JUnit-BEGIN$
 		suite.addTestSuite( Hbm2JavaConstructorTest.class );
-		suite.addTestSuite( Hbm2JavaBidirectionalIndexedCollectionMappingTest.class );
+		suite
+				.addTestSuite( Hbm2JavaBidirectionalIndexedCollectionMappingTest.class );
 		suite.addTestSuite( Hbm2JavaTest.class );
+		suite.addTestSuite( DefaultSchemaCatalogTest.class );
 		suite.addTestSuite( GenerateFromJDBCTest.class );
+		suite.addTestSuite( HashcodeEqualsTest.class );
 		suite.addTestSuite( Hbm2DaoTest.class );
 		suite.addTestSuite( XMLPrettyPrinterTest.class );
 		suite.addTestSuite( Hbm2JavaEjb3Test.class );

Copied: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/UnionSubclass.hbm.xml (from rev 10565, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/UnionSubclass.hbm.xml)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/XMLPrettyPrinterTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/XMLPrettyPrinterTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/XMLPrettyPrinterTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -35,7 +35,17 @@
         
         assertEquals("<basic attrib='1'></basic>\r\n",string);
     }
-    
+   
+    public void testCloseTag() throws IOException, DocumentException, SAXException {
+        
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLPrettyPrinter.prettyPrint(new ByteArrayInputStream("<basic></basic>".getBytes() ), byteArrayOutputStream);
+        
+        String string = byteArrayOutputStream.toString();
+        
+        assertEquals("<basic/>\r\n",string);
+    }
+ 
     public void testDeclarationWithoutValidation() throws IOException, DocumentException, SAXException {
         
         String input = "<hibernate-mapping defaultx-lazy=\"false\"/>";

Copied: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Aliens.hbm.xml (from rev 10565, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Aliens.hbm.xml)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Basic.hbm.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Basic.hbm.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Basic.hbm.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -11,12 +11,14 @@
      (2) Id generation with no arguments.
 -->
     <class name="Basic" table="`bas-ic`">
-    
+        <meta attribute="class-meta" inherit="false">Basic</meta>
+        <meta attribute="class-meta" inherit="false">Basic2</meta>
     	<id name="basicId"
     		length="10"
     		type="string"
 			unsaved-value="null"
     	>
+    	    <meta attribute="id-meta" inherit="false">basicId</meta>
     		<generator class="org.hibernate.id.TableHiLoGenerator">
     			<param name="table">uni_table</param>
     			<param name="column">next_hi_value</param>
@@ -26,12 +28,20 @@
     	<property name="description" 
     		not-null="true" 
     		length="200"
-    		type="string" />
+    		type="string">
+    		  <meta attribute="property-desc" inherit="false">description</meta>
+    		</property>
     		
     	<property name="price" length="3" type="big_decimal" />
     	
     	<property name="numberAvailable" type="int" column="`number-Available`"/>
     	
+    	<set name="aSet">
+    	 <meta attribute="set-desc">anotherone</meta>    	 
+    	 <key/>
+    	 <one-to-many class="Basic"/>
+    	</set>
+    	
 	</class>
 
 </hibernate-mapping>

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -10,6 +10,7 @@
 		//$JUnit-BEGIN$
 		suite.addTest( ManyToManyTest.suite() );
 		suite.addTest( Hbm2HbmXmlTest.suite() );
+		suite.addTest( InheritanceTest.suite() );
 		//$JUnit-END$
 		return suite;
 	}

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -127,6 +127,36 @@
 	
 	}
 
+	public void testMetaAttributes() throws DocumentException {
+		File outputXml = new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Basic.hbm.xml");
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  this.getSAXReader();
+		
+		Document document = xmlReader.read(outputXml);		
+	
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/meta");
+		List list = xpath.selectNodes(document);
+		assertEquals("Expected to get one meta element", 2, list.size());
+		Node node = (Node) list.get(0);
+		assertEquals(node.getText(),"Basic");
+		
+		xpath = DocumentHelper.createXPath("//hibernate-mapping/class/property/meta");
+		list = xpath.selectNodes(document);
+		assertEquals("Expected to get one meta element", 1, list.size());
+		node = (Node) list.get(0);
+		assertEquals(node.getText(),"description");
+		
+		xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set/meta");
+		list = xpath.selectNodes(document);
+		assertEquals("Expected to get one meta element", 1, list.size());
+		node = (Node) list.get(0);
+		assertEquals(node.getText(),"anotherone");
+		
+		
+	}
+	
+	
 	public void testComments() throws DocumentException {
 		File outputXml = new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/ClassFullAttribute.hbm.xml");
 		assertFileAndExists(outputXml);

Copied: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java (from rev 10565, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ManyToManyTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ManyToManyTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ManyToManyTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -17,7 +17,6 @@
 import org.dom4j.DocumentException;
 import org.dom4j.DocumentHelper;
 import org.dom4j.Element;
-import org.dom4j.Node;
 import org.dom4j.XPath;
 import org.dom4j.io.SAXReader;
 import org.hibernate.cfg.Configuration;
@@ -64,7 +63,7 @@
         
     }
 	
-	public void testManyToManyFailureExpected() throws DocumentException {
+	public void testManyToMany() throws DocumentException {
 		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "User.hbm.xml");
 		assertFileAndExists(outputXml);
 
@@ -76,9 +75,16 @@
 		List list = xpath.selectNodes(document);
 		assertEquals("Expected to get one many-to-many element", 1, list.size());
 		Element node = (Element) list.get(0);
-		assertEquals(node.attribute( "class" ).getText(),"Group");
+		assertEquals(node.attribute( "entity-name" ).getText(),"org.hibernate.tool.hbm2x.hbm2hbmxml.Group");
 		
 		
+		xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set");
+		list = xpath.selectNodes(document);
+		assertEquals("Expected to get one set element", 1, list.size());
+		node = (Element) list.get(0);
+		assertEquals(node.attribute( "table" ).getText(),"UserGroup");
+		
+		
 	}
 	
 	

Copied: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat (from rev 10565, trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/Group.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/Group.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/Group.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,35 +0,0 @@
-//$Id: Group.java 5686 2005-02-12 07:27:32Z steveebersole $
-package org.hibernate.tool.stat;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Gavin King
- */
-public class Group {
-	private String name;
-	private Set users = new HashSet();
-	Group() {}
-	public Group(String n) {
-		name = n;
-	}
-	public String getName() {
-		return name;
-	}
-	public void setName(String name) {
-		this.name = name;
-	}
-	public Set getUsers() {
-		return users;
-	}
-	public void setUsers(Set users) {
-		this.users = users;
-	}
-	public void addUser(User user) {
-		users.add(user);
-		
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/Group.java (from rev 10565, trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/Group.java)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/SessionAttribute.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/SessionAttribute.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/SessionAttribute.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,38 +0,0 @@
-//$Id: SessionAttribute.java 5686 2005-02-12 07:27:32Z steveebersole $
-package org.hibernate.tool.stat;
-
-import java.io.Serializable;
-
-/**
- * @author Gavin King
- */
-public class SessionAttribute {
-	private Long id;
-	private String name;
-	private String stringData;
-	
-	SessionAttribute() {}
-	public SessionAttribute(String name) {
-		this.name = name;
-	}
-	public SessionAttribute(String name, String str) {
-		this.name = name;
-		this.stringData = str;
-	}
-	public String getName() {
-		return name;
-	}
-	public void setName(String name) {
-		this.name = name;
-	}
-	public String getStringData() {
-		return stringData;
-	}
-	public void setStringData(String stringData) {
-		this.stringData = stringData;
-	}
-	
-	public Long getId() {
-		return id;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/SessionAttribute.java (from rev 10565, trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/SessionAttribute.java)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,62 +0,0 @@
-package org.hibernate.tool.stat;
-
-import org.hibernate.Transaction;
-import org.hibernate.classic.Session;
-import org.hibernate.tool.NonReflectiveTestCase;
-
-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" );
-	}*/
-	
-	protected void setUp() throws Exception {
-		// TODO Auto-generated method stub
-		super.setUp();
-		if(getSessions()==null) {
-			buildSessionFactory();
-		}
-	}
-	public void testBrowser() throws Exception {
-		getSessions().getStatistics().setStatisticsEnabled( true );
-		
-		new StatisticsBrowser().showStatistics( getSessions().getStatistics(), false );
-		
-		
-		Session s = openSession();
-		Transaction tx = s.beginTransaction();
-		
-		for(int i=0; i<100; i++) {
-			Group group = new Group( "Hibernate" + i );
-			group.addUser(new User("gavin" + i, "figo123"));
-			group.addUser(new User("cbauer" + i, "figo123"));
-			group.addUser(new User("steve" + i, "figo123"));
-			group.addUser(new User("max" + i, "figo123"));
-			group.addUser(new User("anthony" + i, "figo123"));
-
-			s.saveOrUpdate( group );
-			if(i % 20==0) s.flush();
-		}
-		s.flush();
-		s.clear();
-		s.createQuery( "from java.lang.Object" ).list();
-		tx.commit();
-		s.close();
-		
-		Thread.sleep( 100000 );
-		
-	}
-
-	protected String getBaseForMappings() {
-		return "org/hibernate/tool/stat/";
-	}
-	protected String[] getMappings() {
-		return new String[] { "UserGroup.hbm.xml"};
-	}
-
-}

Copied: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java (from rev 10565, trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/StatisticsBrowserTest.java)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/User.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/User.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/User.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,37 +0,0 @@
-//$Id: User.java 5686 2005-02-12 07:27:32Z steveebersole $
-package org.hibernate.tool.stat;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Gavin King
- */
-public class User {
-	private String name;
-	private String password;
-	private Set session = new HashSet();
-	User() {}
-	public User(String n, String pw) {
-		name=n;
-		password = pw;
-	}
-	public String getName() {
-		return name;
-	}
-	public void setName(String name) {
-		this.name = name;
-	}
-	public String getPassword() {
-		return password;
-	}
-	public void setPassword(String password) {
-		this.password = password;
-	}
-	public Set getSession() {
-		return session;
-	}
-	public void setSession(Set session) {
-		this.session = session;
-	}
-}

Copied: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/User.java (from rev 10565, trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/User.java)

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/UserGroup.hbm.xml
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/UserGroup.hbm.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/UserGroup.hbm.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC 
-	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!-- 
-     
--->
-
-<hibernate-mapping package="org.hibernate.tool.stat">
-	
-	<class name="Group" table="groups">
-	    <cache usage="read-write"/>
-		<id name="name"/>
-		<set name="users" cascade="save-update">
-		    <cache usage="read-write"/>
-			<key column="groupName"/>			
-			<one-to-many class="User"/>
-		</set>
-	</class>
-	
-	<class name="User" table="users">
-		<cache usage="read-write"/>
-		<id name="name"/>
-		<property name="password"/>
-		<set name="session" cascade="persist,save-update,delete,delete-orphan">
-			<key column="userName" not-null="true"/>
-			<one-to-many class="SessionAttribute"/>
-		</set>
-	</class>
-	
-	<class name="SessionAttribute" table="session_attributes">
-		<id name="id" access="field">
-			<generator class="native"/>
-		</id>
-		<property name="name" not-null="true" update="false"/>
-		<property name="stringData"/>
-	</class>
-	
-	
-
-</hibernate-mapping>

Copied: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/stat/UserGroup.hbm.xml (from rev 10565, trunk/HibernateExt/tools/src/test/org/hibernate/tool/stat/UserGroup.hbm.xml)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -164,6 +164,7 @@
 		}
 
 		// The directory is now empty so delete it
+		System.out.println("deleting: " + dir);
 		return dir.delete();
 	}
 

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/Jdbc2CfgAllTests.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/Jdbc2CfgAllTests.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/Jdbc2CfgAllTests.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -13,6 +13,7 @@
 		suite.addTest( PerformanceTest.suite() );
 		suite.addTest( NoPrimaryKeyTest.suite() );
 		suite.addTest( SearchEscapeStringTest.suite() );
+		suite.addTest( ManyToManyTest.suite() );
 		suite.addTest( OverrideBinderTest.suite() );
 		suite.addTest( VersioningTest.suite() );
 		suite.addTest( MetaDataTest.suite() );
@@ -21,8 +22,8 @@
 		suite.addTest( OracleCompositeIdOrderTest.suite() );
 		suite.addTest( ForeignKeysTest.suite() );
 		suite.addTest( RevEngForeignKeyTests.suite() );
+		suite.addTest( OracleViewsTest.suite() );
 		suite.addTest( BasicTest.suite() );
-		suite.addTest( OracleViewsTest.suite() );
 		suite.addTest( AutoQuoteTest.suite() );
 		suite.addTest( KeyPropertyCompositeIdTest.suite() );
 		suite.addTest( PersistentClassesTest.suite() );

Copied: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/ManyToManyTest.java (from rev 10565, trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/ManyToManyTest.java)

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -4,6 +4,7 @@
  */
 package org.hibernate.tool.test.jdbc2cfg;
 
+import java.io.File;
 import java.sql.Types;
 import java.util.Iterator;
 import java.util.List;
@@ -12,6 +13,7 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.hibernate.cfg.Configuration;
 import org.hibernate.cfg.Environment;
 import org.hibernate.cfg.JDBCMetaDataConfiguration;
 import org.hibernate.cfg.Settings;
@@ -26,11 +28,13 @@
 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;
 import org.hibernate.mapping.Table;
 import org.hibernate.tool.JDBCMetaDataBinderTestCase;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
 
 /**
  * @author max
@@ -169,6 +173,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();
 		
@@ -184,8 +197,6 @@
 		assertNull(repository.getTableIdentifierProperties(new TableIdentifier("blah")));
 		TableIdentifier ordersTable = new TableIdentifier(null,null, "ORDERS");
 		
-		
-		
 		assertEquals("customOrderId", repository.tableToIdentifierPropertyName(ordersTable));
 		assertEquals(null, repository.tableToIdentifierPropertyName(new TableIdentifier("blah")));
 		
@@ -219,7 +230,6 @@
 		assertNotNull(sv.getIdentifierGeneratorProperties());
 		assertEquals("seq_table", sv.getIdentifierGeneratorProperties().getProperty("table"));
 		
-		
 	}
 	
 	
@@ -425,6 +435,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();
@@ -437,6 +492,7 @@
 		return ( (SimpleValue)property.getValue() ).getTypeName();
 	}
 
+
 	
 	
 	protected String[] getCreateSQL() {

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -24,6 +24,7 @@
 import org.hibernate.mapping.Property;
 import org.hibernate.mapping.Set;
 import org.hibernate.tool.JDBCMetaDataBinderTestCase;
+import org.hibernate.tool.stat.StatisticsBrowser;
 
 import persistentclasses.Item;
 import persistentclasses.Orders;
@@ -116,6 +117,8 @@
 		
 		SessionFactory sf = cfg.buildSessionFactory();
 		
+		
+		
 		Session session = sf.openSession();
         Transaction t = session.beginTransaction();
 	
@@ -135,6 +138,7 @@
 		t.commit();
 		session.close();
 		
+		new StatisticsBrowser().showStatistics( sf.getStatistics(), true );
 		session = sf.openSession();
 		t = session.beginTransaction();
 		

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/foreignkeytest.reveng.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/foreignkeytest.reveng.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/foreignkeytest.reveng.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -16,5 +16,6 @@
 	    	<set property="managedProjects"/>
 	    </foreign-key>
 	</table>	
-
+	
+	
 </hibernate-reverse-engineering>
\ No newline at end of file

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/newformat.reveng.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/newformat.reveng.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/newformat.reveng.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,128 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
-
-<hibernate-reverse-engineering case-match="exact|upper|lower">
-
-   <!-- .* is valid, will be translated into % -->
-   <database-selection match-catalog="PUBLIC.*" match-schema="OVRTEST" match-table=".*"/> 
-    
-    <type-mapping>
-		<from-sql-type native-type="varchar" jdbc-type="VARCHAR" length='20'>
-		  <hibernate-type name="SomeUserType"><param></param></hibernate-type>
-		</from-sql-type>
-	</type-mapping>
-
-	<table-filter match-schema=".*" match-name="TBL_.*">
-      <entity package="org.werd"/>
-	</table-filter>
-	
-	
-	<table-filter match-name="DEFUNCT_TABLE" exclude="true" />
-	<table-filter match-name="DoNotWantIt" exclude="true" />
-	<table-filter match-name="WantedTable" />
-	<table-filter match-catalog="BAD" match-schema="SCHEMA"
-		match-name=".*" exclude="true" />
-
-	<table-filter match-catalog=".*" match-schema=".*"
-		match-name="BIN$.*" exclude="true" />
-		
-	<table-filter match-name=".*" exclude="false"/>
-	<!-- 
-		<table name="CUSTOMER" package="org.funk" class-name="MyCustomer">
-		<column name="order" property-name="orderName" />
-		</table> 
-		
-		<table name="CUSTOMER">
-		<column name="ORDER" />
-		</table>
-		
-		<table catalog="CUSTOMER" schema="WHATEVER" name="ORDER">
-		<column name="name" exclude="true">
-		<meta attribute="property-name">Name</meta>
-		</column>
-		</table>
-	-->
-
-<!-- hack for disable many-to-many 
-    <table name="CategoryItem">
-		<foreign-key constraint-name="CAT_FK" foreign-table="CATEGORY" >
-			 <column-ref local-column="catid" foreign-column="id" />
-			 <many-to-one name="dfdf"/>
-		</foreign-key>
-    </table>
--->    
-	<!-- 
-		alter table Customer add constraint 'max' foreign key (addressid, x) references address (dfdf)
-		
-		default_schema PUBLIC
-	-->
-	<table name="ORDERS" class="Order">
-		<primary-key property="id" key-class="OrderId">
-			<generator class="sequence">
-				<param name="table">seq_table</param>
-			</generator>
-			<key-column name="CUSTID1" property="val1" type="string"/> <!--  no exclude -->
-			<key-column name="CUSTID2" />			
-			<key-column name="CUSTID3" />			
-		</primary-key>
-
-	    <column name="generated" exclude="true" property="price"/>
-
-	    <for-columns exclude="false" property="price" type="MonetaryAmount">
-  		 <column name="PRICE"/>
-   		 <column name="CURRENCY"/>
-	    </for-columns>
-	    
-        <!-- if constraint-name exist in db, use it! ignore foreign-x -->
-		<foreign-key constraint-name="SYS_CP20" foreign-table="PARENT" >
-			 <column-ref local-column="parentid" foreign-column="id" />
-			 <column-ref local-column="extraparentid" foreign-column="extraid" />
-		     <many-to-one property="order"/>
-		     <set name="orders"/>
-		</foreign-key>
-
-
-		<foreign-key constraint-name="SYS_CP20" foreign-table="PARENT" >
-			 <column-ref local-column="parentid" foreign-column="id" />
-			 <column-ref local-column="extraparentid" foreign-column="extraid" />
-		    <many-to-one property="order"/>
-		    <map name="orders">
-		      <map-key column="xxx"/>
-		    </map>
-		</foreign-key>
-		
-		<foreign-key foreign-table="PARENT">
-			<column-ref local-column="parentid" foreign-column="id" />
-			<column-ref local-column="extraparentid" foreign-column="extraid" />
-		</foreign-key>
-		
-		
-						bidirectionality
-				cardinality
-				
-				entity-name
-				collection-name
-								
-				<many-to-one ...>
-				<
-		
-		
-	</table>
-
-
-	<table name="CHILDREN">
-		<foreign-key foreign-table="PARENT">
-			<column-ref local-column="parentid" foreign-column="id" />
-			<column-ref local-column="extraparentid"
-				foreign-column="extraid" />
-		</foreign-key>
-	</table>
-
-    <table name="EXCOLUMNS">
-    	<column name="EXCOLUMN" exclude="true"/>
-    </table>
-    
-   <table name="TblTest" class="org.test.Test"/>
-   		
-
-</hibernate-reverse-engineering>
\ No newline at end of file

Modified: branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/overridetest.reveng.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/overridetest.reveng.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/overridetest.reveng.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -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: branches/Lucene_Integration/HibernateExt/tools/src/testsupport/NoopReverseEngineeringStrategy.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/testsupport/NoopReverseEngineeringStrategy.java	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/testsupport/NoopReverseEngineeringStrategy.java	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,4 +1,5 @@
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 
 import org.hibernate.cfg.reveng.ReverseEngineeringSettings;
@@ -6,6 +7,8 @@
 import org.hibernate.cfg.reveng.TableIdentifier;
 import org.hibernate.connection.ConnectionProvider;
 import org.hibernate.exception.SQLExceptionConverter;
+import org.hibernate.mapping.ForeignKey;
+import org.hibernate.mapping.Table;
 
 /**
  * noop naming strategy for testing validation of parameters in ant test.
@@ -140,4 +143,24 @@
 		// TODO Auto-generated method stub
 		
 	}
+
+	public boolean isManyToManyTable(Table table) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public String foreignKeyToManyToManyName(ForeignKey fromKey, TableIdentifier middleTable, ForeignKey toKey, boolean uniqueReference) {
+		// 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;
+	}
 }

Modified: branches/Lucene_Integration/HibernateExt/tools/src/testsupport/anttest-build.xml
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/testsupport/anttest-build.xml	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/testsupport/anttest-build.xml	2006-10-11 04:01:11 UTC (rev 10566)
@@ -59,7 +59,7 @@
 )
    </sql>    -->
 		<hibernatetool destdir="${build.dir}/bottomup">
-			<jdbcconfiguration propertyfile="../../etc/hibernate.properties" />
+			<jdbcconfiguration propertyfile="../../etc/hibernate.properties" detectManyToMany="true" detectoptimisticlock="true"/>
 
 			<hbm2java />
 			<hbm2java templatepath="templates" />
@@ -210,7 +210,7 @@
 		<copy file="ejb3test-hibernate.cfg.xml" tofile="${build.dir}/ejb3/classes/ejb3test-hibernate.cfg.xml" />
 
 		<hibernatetool destdir="${build.dir}">
-			<ejb3configuration />
+			<ejb3configuration/>
 			<classpath>
 				<path location="${build.dir}/ejb3/classes" />
 			</classpath>
@@ -220,6 +220,95 @@
 		<antcall target="afterCfg2hbm" />
 	</target>
 
+	<target name="jpa-boguspunit">
+		<path id="annlib">
+			<path location="${build.dir}/../../lib/freemarker.jar" />
+
+			<path location="${build.dir}/../../lib/testlibs/hibernate3.jar" />
+			<path location="${build.dir}/../../lib/testlibs/hibernate-annotations.jar" />
+			<path location="${build.dir}/../../lib/testlibs/ejb3-persistence.jar" />
+			<path location="${build.dir}/../../lib/testlibs/hibernate-entitymanager.jar" />
+			<path location="${build.dir}/../../lib/testlibs/jboss-archive-browsing.jar" />
+			<path location="${build.dir}/../../lib/testlibs/javaassist.jar" /> 
+			<path location="${build.dir}/../classes" />
+			<path location="${hibernate-core.home}\jdbc\hsqldb.jar" />
+			<!--	            <fileset dir="${hibernate-core.lib.dir}">
+	               
+	            </fileset>-->
+		</path>
+		<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="annlib" />
+
+		<delete dir="${build.dir}/ejb3" />
+		<mkdir dir="${build.dir}/ejb3" />
+
+		<antcall target="prepareCfg2hbm" />
+		<hibernatetool>
+			<jdbcconfiguration propertyfile="../../etc/hibernate.properties" />
+			<hbm2java ejb3="true" jdk5="true" destdir="${build.dir}/ejb3/src" />
+		</hibernatetool>
+
+		<mkdir dir="${build.dir}/ejb3/classes" />
+		<javac classpathref="annlib" srcdir="${build.dir}/ejb3/src" destdir="${build.dir}/ejb3/classes" />
+
+		<copy file="ejb3test-persistence.xml" tofile="${build.dir}/ejb3/classes/META-INF/persistence.xml" />
+		<copy file="ejb3test-hibernate.cfg.xml" tofile="${build.dir}/ejb3/classes/ejb3test-hibernate.cfg.xml" />
+
+		<hibernatetool destdir="${build.dir}">
+			<jpaconfiguration persistenceunit="shouldnotbethere"/>
+			<classpath>
+				<path location="${build.dir}/ejb3/classes" />
+			</classpath>
+			<hbm2ddl export="false" outputfilename="ejb3.sql" />
+		</hibernatetool>
+
+		<antcall target="afterCfg2hbm" />
+	</target>
+
+	<target name="jpa-punit">
+		<path id="annlib">
+			<path location="${build.dir}/../../lib/freemarker.jar" />
+
+			<path location="${build.dir}/../../lib/testlibs/hibernate3.jar" />
+			<path location="${build.dir}/../../lib/testlibs/hibernate-annotations.jar" />
+			<path location="${build.dir}/../../lib/testlibs/ejb3-persistence.jar" />
+			<path location="${build.dir}/../../lib/testlibs/hibernate-entitymanager.jar" />
+			<path location="${build.dir}/../../lib/testlibs/jboss-archive-browsing.jar" />
+			<path location="${build.dir}/../../lib/testlibs/javaassist.jar" /> 
+			<path location="${build.dir}/../classes" />
+			<path location="${hibernate-core.home}\jdbc\hsqldb.jar" />
+			<!--	            <fileset dir="${hibernate-core.lib.dir}">
+	               
+	            </fileset>-->
+		</path>
+		<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="annlib" />
+
+		<delete dir="${build.dir}/ejb3" />
+		<mkdir dir="${build.dir}/ejb3" />
+
+		<antcall target="prepareCfg2hbm" />
+		<hibernatetool>
+			<jdbcconfiguration propertyfile="../../etc/hibernate.properties" />
+			<hbm2java ejb3="true" jdk5="true" destdir="${build.dir}/ejb3/src" />
+		</hibernatetool>
+
+		<mkdir dir="${build.dir}/ejb3/classes" />
+		<javac classpathref="annlib" srcdir="${build.dir}/ejb3/src" destdir="${build.dir}/ejb3/classes" />
+
+		<copy file="ejb3test-persistence.xml" tofile="${build.dir}/ejb3/classes/META-INF/persistence.xml" />
+		<copy file="ejb3test-hibernate.cfg.xml" tofile="${build.dir}/ejb3/classes/ejb3test-hibernate.cfg.xml" />
+
+		<hibernatetool destdir="${build.dir}">
+			<jpaconfiguration persistenceunit="ejb3test"/>
+			<classpath>
+				<path location="${build.dir}/ejb3/classes" />
+			</classpath>
+			<hbm2ddl export="false" outputfilename="ejb3.sql" />
+		</hibernatetool>
+
+		<antcall target="afterCfg2hbm" />
+	</target>
+
+	
 	<target name="testantejb3hbm2java">
 		<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="tasks.classpath" />
 
@@ -346,4 +435,18 @@
 		
 		<antcall target="afterCfg2hbm" />
 	</target>
+	
+
+	<target name="noconfig-shoulderror">
+		<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="tasks.classpath" />
+		<hibernatetool destdir="${basedir}/target"> 
+		 <classpath refid="full.path"/> 
+		 <!--configuration configurationfile="${basedir}/src/main/webapp/WEB-INF/classes/hibernate.cfg.xml"> 
+		 <fileset dir="${basedir}/src/main/webapp/WEB-INF/classes" includes="**/*hbm.xml" excludes="**/Application.hbm.xml"/> 
+		 </configuration--> 
+
+		 <hbm2ddl drop="true" create="true" export="true" outputfilename="generated-schema.sql" delimiter=";" format="true" /> 
+		 <hbm2doc />
+		</hibernatetool>
+	</target>
 </project>

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-class.vm
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-class.vm	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-class.vm	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,10 +0,0 @@
-name=$item.getName()
-pojo=$pojo.getDeclarationName()
-unsetproperty=$unsetProperty
-proptest=$proptest
-hibernatetool.booleanProperty=$ctx.get("hibernatetool.booleanProperty")
-booleanProperty=$booleanProperty
-#if($booleanProperty==false)
-booleanWasTrue=true
-#end
-myTool.value=$myTool.unqualify("myTool.value")

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-content.vm
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-content.vm	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-content.vm	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1 +0,0 @@
-File for $item in $version

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-test.vm
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-test.vm	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-test.vm	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1,4 +0,0 @@
-#foreach( $item in $ctx.getKeys()) 
-	$templates.create("generictemplates/pojo/generic-content.vm", "${item}.txt") 
-#end
-

Deleted: branches/Lucene_Integration/HibernateExt/tools/src/testsupport/templates/pojo/Pojo.vm
===================================================================
--- branches/Lucene_Integration/HibernateExt/tools/src/testsupport/templates/pojo/Pojo.vm	2006-10-05 06:08:25 UTC (rev 10565)
+++ branches/Lucene_Integration/HibernateExt/tools/src/testsupport/templates/pojo/Pojo.vm	2006-10-11 04:01:11 UTC (rev 10566)
@@ -1 +0,0 @@
-/** Made by a template in your neighborhood */
\ No newline at end of file




More information about the hibernate-commits mailing list