You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(22) |
Nov
(308) |
Dec
(131) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(369) |
Feb
(171) |
Mar
(236) |
Apr
(187) |
May
(218) |
Jun
(217) |
Jul
(127) |
Aug
(448) |
Sep
(270) |
Oct
(231) |
Nov
(422) |
Dec
(255) |
| 2004 |
Jan
(111) |
Feb
(73) |
Mar
(338) |
Apr
(351) |
May
(349) |
Jun
(495) |
Jul
(394) |
Aug
(1048) |
Sep
(499) |
Oct
(142) |
Nov
(269) |
Dec
(638) |
| 2005 |
Jan
(825) |
Feb
(1272) |
Mar
(593) |
Apr
(690) |
May
(950) |
Jun
(958) |
Jul
(767) |
Aug
(839) |
Sep
(525) |
Oct
(449) |
Nov
(585) |
Dec
(455) |
| 2006 |
Jan
(603) |
Feb
(656) |
Mar
(195) |
Apr
(114) |
May
(136) |
Jun
(100) |
Jul
(128) |
Aug
(68) |
Sep
(7) |
Oct
(1) |
Nov
(1) |
Dec
(8) |
| 2007 |
Jan
(4) |
Feb
(3) |
Mar
(8) |
Apr
(16) |
May
(5) |
Jun
(4) |
Jul
(6) |
Aug
(23) |
Sep
(15) |
Oct
(5) |
Nov
(7) |
Dec
(5) |
| 2008 |
Jan
(5) |
Feb
(1) |
Mar
(1) |
Apr
(5) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(2) |
| 2013 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
| 2015 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <hib...@li...> - 2006-06-21 19:43:09
|
Author: ste...@jb...
Date: 2006-06-21 15:42:52 -0400 (Wed, 21 Jun 2006)
New Revision: 10036
Modified:
trunk/Hibernate3/src/org/hibernate/loader/custom/CustomLoader.java
Log:
2 minor bugs in "auto discovery"
Modified: trunk/Hibernate3/src/org/hibernate/loader/custom/CustomLoader.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/loader/custom/CustomLoader.java 2006-06-21 18:39:42 UTC (rev 10035)
+++ trunk/Hibernate3/src/org/hibernate/loader/custom/CustomLoader.java 2006-06-21 19:42:52 UTC (rev 10036)
@@ -96,6 +96,8 @@
final Return rtn = ( Return ) itr.next();
if ( rtn instanceof ScalarReturn ) {
ScalarReturn scalarRtn = ( ScalarReturn ) rtn;
+ resultTypes.add( scalarRtn.getType() );
+ specifiedAliases.add( scalarRtn.getColumnAlias() );
resultColumnProcessors.add(
new ScalarResultColumnProcessor(
scalarRtn.getColumnAlias(),
@@ -103,8 +105,6 @@
resultTypes.size()
)
);
- resultTypes.add( scalarRtn.getType() );
- specifiedAliases.add( scalarRtn.getColumnAlias() );
hasScalars = true;
}
else if ( rtn instanceof RootReturn ) {
@@ -450,7 +450,6 @@
}
public void performDiscovery(ResultSetMetaData resultSetMetaData, List types, List aliases) {
- throw new HibernateException( "cannot perform autodiscovery on queries with non-scalar results" );
}
}
|
|
From: <hib...@li...> - 2006-06-21 18:39:49
|
Author: max...@jb...
Date: 2006-06-21 14:39:42 -0400 (Wed, 21 Jun 2006)
New Revision: 10035
Added:
trunk/Hibernate3/test/org/hibernate/test/sql/Order.java
trunk/Hibernate3/test/org/hibernate/test/sql/Product.java
Modified:
trunk/Hibernate3/test/org/hibernate/test/sql/General.hbm.xml
Log:
missing adds
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/General.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/General.hbm.xml 2006-06-21 12:50:39 UTC (rev 10034)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/General.hbm.xml 2006-06-21 18:39:42 UTC (rev 10035)
@@ -30,6 +30,7 @@
<generator class="increment"/>
</id>
<property name="name" column="NAME" not-null="true"/>
+
</class>
<class name="Employment" table="EMPLOYMENT">
@@ -46,7 +47,37 @@
<column name="CURRENCY"/>
</property>
</class>
-
+
+ <class name="Order" table="TBL_ORDER">
+ <composite-id name="orderId" class="Order$OrderId">
+ <key-property name="orgid"/>
+ <key-property name="ordernumber"/>
+ </composite-id>
+
+ <many-to-one name="product">
+ <column name="PROD_ORGID"/>
+ <column name="PROD_NO"/>
+ </many-to-one>
+ <many-to-one name="person"/>
+ </class>
+
+ <class name="Product">
+ <composite-id name="productId" class="Product$ProductId">
+ <key-property name="orgid"/>
+ <key-property name="productnumber"/>
+ </composite-id>
+
+ <property name="name"/>
+
+ <set name="orders" inverse="true">
+ <key>
+ <column name="PROD_ORGID"/>
+ <column name="PROD_NO"/>
+ </key>
+ <one-to-many class="Order"/>
+ </set>
+ </class>
+
<resultset name="org-emp-regionCode">
<return-scalar column="regionCode" type="string"/>
<return alias="org" class="Organization"/>
Added: trunk/Hibernate3/test/org/hibernate/test/sql/Order.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/Order.java 2006-06-21 12:50:39 UTC (rev 10034)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/Order.java 2006-06-21 18:39:42 UTC (rev 10035)
@@ -0,0 +1,55 @@
+package org.hibernate.test.sql;
+
+import java.io.Serializable;
+
+public class Order {
+
+ static public class OrderId implements Serializable {
+ String orgid;
+ String ordernumber;
+ public String getOrdernumber() {
+ return ordernumber;
+ }
+ public void setOrdernumber(String ordernumber) {
+ this.ordernumber = ordernumber;
+ }
+ public String getOrgid() {
+ return orgid;
+ }
+ public void setOrgid(String orgid) {
+ this.orgid = orgid;
+ }
+
+
+ }
+
+ OrderId orderId;
+
+ Product product;
+
+ Person person;
+
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public OrderId getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(OrderId orderId) {
+ this.orderId = orderId;
+ }
+
+ public Product getProduct() {
+ return product;
+ }
+
+ public void setProduct(Product product) {
+ this.product = product;
+ }
+
+}
Added: trunk/Hibernate3/test/org/hibernate/test/sql/Product.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/Product.java 2006-06-21 12:50:39 UTC (rev 10034)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/Product.java 2006-06-21 18:39:42 UTC (rev 10035)
@@ -0,0 +1,66 @@
+package org.hibernate.test.sql;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+public class Product {
+
+ static public class ProductId implements Serializable {
+ String orgid;
+ String productnumber;
+ public String getProductnumber() {
+ return productnumber;
+ }
+ public void setProductnumber(String ordernumber) {
+ this.productnumber = ordernumber;
+ }
+ public String getOrgid() {
+ return orgid;
+ }
+ public void setOrgid(String orgid) {
+ this.orgid = orgid;
+ }
+
+
+ }
+
+ ProductId productId;
+
+ String name;
+
+ Person person;
+
+ Set orders = new HashSet();
+
+ public Set getOrders() {
+ return orders;
+ }
+
+ public void setOrders(Set orders) {
+ this.orders = orders;
+ }
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public ProductId getProductId() {
+ return productId;
+ }
+
+ public void setProductId(ProductId orderId) {
+ this.productId = orderId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String product) {
+ this.name = product;
+ }
+
+}
|
|
From: <hib...@li...> - 2006-06-21 12:50:42
|
Author: epbernard
Date: 2006-06-21 08:50:39 -0400 (Wed, 21 Jun 2006)
New Revision: 10034
Modified:
trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/QueryBinder.java
trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java
Log:
Allow annotations to compile with last core change
Native queries are broken though
Modified: trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/QueryBinder.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/QueryBinder.java 2006-06-21 06:23:30 UTC (rev 10033)
+++ trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/QueryBinder.java 2006-06-21 12:50:39 UTC (rev 10034)
@@ -24,9 +24,8 @@
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.engine.NamedQueryDefinition;
import org.hibernate.engine.NamedSQLQueryDefinition;
-import org.hibernate.loader.custom.SQLQueryReturn;
-import org.hibernate.loader.custom.SQLQueryRootReturn;
-import org.hibernate.loader.custom.SQLQueryScalarReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
/**
* Query binder
@@ -97,12 +96,11 @@
else if ( ! void.class.equals( queryAnn.resultClass() ) ) {
//class mapping usage
//FIXME should be done in a second pass due to entity name?
- final SQLQueryRootReturn entityQueryReturn =
- new SQLQueryRootReturn( "alias1", queryAnn.resultClass().getName(), new HashMap(), LockMode.READ );
+ final NativeSQLQueryRootReturn entityQueryReturn =
+ new NativeSQLQueryRootReturn( "alias1", queryAnn.resultClass().getName(), new HashMap(), LockMode.READ );
query = new NamedSQLQueryDefinition(
queryName,
- new SQLQueryReturn[]{entityQueryReturn},
- new SQLQueryScalarReturn[0],
+ new NativeSQLQueryReturn[]{entityQueryReturn},
null,
getBoolean( queryName, "org.hibernate.cacheable", hints ),
getString( queryName, "org.hibernate.cacheRegion", hints ),
@@ -159,12 +157,11 @@
else if ( ! void.class.equals( queryAnn.resultClass() ) ) {
//class mapping usage
//FIXME should be done in a second pass due to entity name?
- final SQLQueryRootReturn entityQueryReturn =
- new SQLQueryRootReturn( "alias1", queryAnn.resultClass().getName(), new HashMap(), LockMode.READ );
+ final NativeSQLQueryRootReturn entityQueryReturn =
+ new NativeSQLQueryRootReturn( "alias1", queryAnn.resultClass().getName(), new HashMap(), LockMode.READ );
query = new NamedSQLQueryDefinition(
queryAnn.query(),
- new SQLQueryReturn[]{entityQueryReturn},
- new SQLQueryScalarReturn[0],
+ new NativeSQLQueryReturn[]{entityQueryReturn},
null,
queryAnn.cacheable(),
AnnotationBinder.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
Modified: trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java 2006-06-21 06:23:30 UTC (rev 10033)
+++ trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java 2006-06-21 12:50:39 UTC (rev 10034)
@@ -21,8 +21,8 @@
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.QuerySecondPass;
import org.hibernate.engine.ResultSetMappingDefinition;
-import org.hibernate.loader.custom.SQLQueryRootReturn;
-import org.hibernate.loader.custom.SQLQueryScalarReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryScalarReturn;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
@@ -141,15 +141,15 @@
}
propertyresults = propertyresults.isEmpty() ? CollectionHelper.EMPTY_MAP : propertyresults;
- SQLQueryRootReturn result =
- new SQLQueryRootReturn(
+ NativeSQLQueryRootReturn result =
+ new NativeSQLQueryRootReturn(
"alias" + entityAliasIndex++, entity.entityClass().getName(), propertyresults, LockMode.READ
);
- definition.addEntityQueryReturn( result );
+ definition.addQueryReturn( result );
}
for ( ColumnResult column : ann.columns() ) {
- definition.addScalarQueryReturn( new SQLQueryScalarReturn( column.name(), null ) );
+ definition.addQueryReturn( new NativeSQLQueryScalarReturn( column.name(), null ) );
}
if (isDefault) {
|
|
From: <hib...@li...> - 2006-06-21 06:23:33
|
Author: chr...@jb...
Date: 2006-06-21 02:23:30 -0400 (Wed, 21 Jun 2006)
New Revision: 10033
Modified:
trunk/Hibernate3/src/org/hibernate/util/DTDEntityResolver.java
Log:
Fixed copy/paste error in log message
Modified: trunk/Hibernate3/src/org/hibernate/util/DTDEntityResolver.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/util/DTDEntityResolver.java 2006-06-21 06:23:09 UTC (rev 10032)
+++ trunk/Hibernate3/src/org/hibernate/util/DTDEntityResolver.java 2006-06-21 06:23:30 UTC (rev 10033)
@@ -62,7 +62,7 @@
log.debug( "unable to locate [" + systemId + "] on classpath" );
}
else {
- log.debug( "located [" + systemId + "] on classpath" );
+ log.debug( "located [" + systemId + "] in classpath" );
InputSource source = new InputSource( stream );
source.setPublicId( publicId );
source.setSystemId( systemId );
|
|
From: <hib...@li...> - 2006-06-21 06:23:13
|
Author: chr...@jb...
Date: 2006-06-21 02:23:09 -0400 (Wed, 21 Jun 2006)
New Revision: 10032
Modified:
trunk/Hibernate3/src/org/hibernate/util/DTDEntityResolver.java
Log:
Fixed copy/paste error in log message
Modified: trunk/Hibernate3/src/org/hibernate/util/DTDEntityResolver.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/util/DTDEntityResolver.java 2006-06-20 12:19:30 UTC (rev 10031)
+++ trunk/Hibernate3/src/org/hibernate/util/DTDEntityResolver.java 2006-06-21 06:23:09 UTC (rev 10032)
@@ -62,7 +62,7 @@
log.debug( "unable to locate [" + systemId + "] on classpath" );
}
else {
- log.debug( "unable to locate [" + systemId + "] on classpath" );
+ log.debug( "located [" + systemId + "] on classpath" );
InputSource source = new InputSource( stream );
source.setPublicId( publicId );
source.setSystemId( systemId );
|
|
From: <hib...@li...> - 2006-06-20 12:19:35
|
Author: max...@jb...
Date: 2006-06-20 08:19:30 -0400 (Tue, 20 Jun 2006)
New Revision: 10031
Modified:
trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
Log:
failureExpected for composite id joins
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-06-20 11:52:41 UTC (rev 10030)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-06-20 12:19:30 UTC (rev 10031)
@@ -326,7 +326,8 @@
s.close();
}
- public void testCompositeIdJoins() {
+ /* test for native sql composite id joins which has never been implemented */
+ public void testCompositeIdJoinsFailureExpected() {
Session s = openSession();
Transaction t = s.beginTransaction();
Person person = new Person();
|
|
From: <hib...@li...> - 2006-06-20 11:52:52
|
Author: max...@jb...
Date: 2006-06-20 07:52:41 -0400 (Tue, 20 Jun 2006)
New Revision: 10030
Modified:
trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
trunk/HibernateExt/tools/src/templates/hbm/sql-query.hbm.ftl
Log:
update to latest core native sql changes
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2006-06-20 10:56:01 UTC (rev 10029)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2006-06-20 11:52:41 UTC (rev 10030)
@@ -12,10 +12,10 @@
import org.hibernate.FetchMode;
import org.hibernate.cfg.Configuration;
import org.hibernate.engine.Versioning;
-import org.hibernate.loader.custom.SQLQueryCollectionReturn;
-import org.hibernate.loader.custom.SQLQueryJoinReturn;
-import org.hibernate.loader.custom.SQLQueryReturn;
-import org.hibernate.loader.custom.SQLQueryRootReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryCollectionReturn;
+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.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Formula;
@@ -138,23 +138,38 @@
return nsqlqry == null || nsqlqry.isEmpty() ? false : true;
}
- public String getNamedSQLReturnTag(SQLQueryReturn sqlret) {
+ public String getNamedSQLReturnTag(NativeSQLQueryReturn sqlret) {
String retVal = "return";
- if (isNamedSQLReturnRole(sqlret) ) retVal = "return-join";
- else if (isNamedSQLReturnCollection(sqlret) ) retVal = "load-collection";
+ if (isNamedSQLReturnRole(sqlret) ) {
+ retVal = "return-join";
+ }
+ else if (isNamedSQLReturnCollection(sqlret) ) {
+ retVal = "load-collection";
+ }
return retVal;
}
- public boolean isNamedSQLReturnRoot(SQLQueryReturn sqlret) {
- return sqlret instanceof SQLQueryRootReturn;
+ public String getNamedSQLReturnProperty(NativeSQLQueryJoinReturn o) {
+ /*if(o instanceof NativeSQLQueryCollectionReturn) {
+ return ((NativeSQLQueryCollectionReturn)o).getOwnerEntityName() + "." + ((NativeSQLQueryCollectionReturn)o).getOwnerProperty();
+ }*/
+ return o.getOwnerAlias() + "." + o.getOwnerProperty();
}
- public boolean isNamedSQLReturnCollection(SQLQueryReturn sqlret) {
- return sqlret instanceof SQLQueryCollectionReturn;
+ public String getNamedSQLReturnRole(NativeSQLQueryCollectionReturn o) {
+ return o.getOwnerEntityName() + "." + o.getOwnerProperty();
}
+
+ public boolean isNamedSQLReturnRoot(NativeSQLQueryReturn sqlret) {
+ return sqlret instanceof NativeSQLQueryRootReturn;
+ }
+
+ public boolean isNamedSQLReturnCollection(NativeSQLQueryReturn sqlret) {
+ return sqlret instanceof NativeSQLQueryCollectionReturn;
+ }
- public boolean isNamedSQLReturnRole(SQLQueryReturn sqlret) {
- return sqlret instanceof SQLQueryJoinReturn;
+ public boolean isNamedSQLReturnRole(NativeSQLQueryReturn sqlret) {
+ return sqlret instanceof NativeSQLQueryJoinReturn;
}
public boolean isFilterDefinitions(Configuration cfg) {
Modified: trunk/HibernateExt/tools/src/templates/hbm/sql-query.hbm.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/hbm/sql-query.hbm.ftl 2006-06-20 10:56:01 UTC (rev 10029)
+++ trunk/HibernateExt/tools/src/templates/hbm/sql-query.hbm.ftl 2006-06-20 11:52:41 UTC (rev 10030)
@@ -1,4 +1,6 @@
-<#foreach queryKey in cfg.namedSQLQueries.keySet()><#assign queryDef = cfg.namedSQLQueries.get(queryKey)> <sql-query
+<#foreach queryKey in cfg.namedSQLQueries.keySet()>
+<#assign queryDef = cfg.namedSQLQueries.get(queryKey)>
+ <sql-query
name="${queryKey}"
<#if queryDef.flushMode?exists>
flush-mode="${queryDef.flushMode.toString().toLowerCase()}"
|
|
From: <hib...@li...> - 2006-06-20 10:56:05
|
Author: max...@jb...
Date: 2006-06-20 06:56:01 -0400 (Tue, 20 Jun 2006)
New Revision: 10029
Modified:
trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
Log:
added mixed scalar/entity test
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-06-20 10:27:37 UTC (rev 10028)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-06-20 10:56:01 UTC (rev 10029)
@@ -48,6 +48,10 @@
return "SELECT * FROM EMPLOYMENT";
}
+ protected String getEmploymentSQLMixedScalarEntity() {
+ return "SELECT e.*, e.employer as employerid FROM EMPLOYMENT e" ;
+ }
+
protected String getOrgEmpRegionSQL() {
return "select {org.*}, {emp.*}, emp.REGIONCODE " +
"from ORGANIZATION org " +
@@ -321,7 +325,74 @@
t.commit();
s.close();
}
+
+ public void testCompositeIdJoins() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ Person person = new Person();
+ person.setName( "Noob" );
+ Product product = new Product();
+ product.setProductId( new Product.ProductId() );
+ product.getProductId().setOrgid( "x" );
+ product.getProductId().setProductnumber( "1234" );
+ product.setName( "Hibernate 3" );
+
+ Order order = new Order();
+ order.setOrderId( new Order.OrderId() );
+ order.getOrderId().setOrdernumber( "1" );
+ order.getOrderId().setOrgid( "y" );
+
+ product.getOrders().add( order );
+ order.setProduct( product );
+ order.setPerson( person );
+
+ s.save( product );
+ s.save( order);
+ s.save( person );
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ Product p = (Product) s.createQuery( "from Product p join fetch p.orders" ).list().get(0);
+ assertTrue(Hibernate.isInitialized( p.getOrders()));
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ Object[] o = (Object[]) s.createSQLQuery( "select\r\n" +
+ " product.orgid as {product.id.orgid}," +
+ " product.productnumber as {product.id.productnumber}," +
+ " {prod_orders}.orgid as orgid3_1_,\r\n" +
+ " {prod_orders}.ordernumber as ordernum2_3_1_,\r\n" +
+ " product.name as {product.name}," +
+ " {prod_orders.element.*}," +
+ /*" orders.PROD_NO as PROD4_3_1_,\r\n" +
+ " orders.person as person3_1_,\r\n" +
+ " orders.PROD_ORGID as PROD3_0__,\r\n" +
+ " orders.PROD_NO as PROD4_0__,\r\n" +
+ " orders.orgid as orgid0__,\r\n" +
+ " orders.ordernumber as ordernum2_0__ \r\n" +*/
+ " from\r\n" +
+ " Product product \r\n" +
+ " inner join\r\n" +
+ " TBL_ORDER {prod_orders} \r\n" +
+ " on product.orgid={prod_orders}.PROD_ORGID \r\n" +
+ " and product.productnumber={prod_orders}.PROD_NO" )
+ .addEntity( "product", Product.class )
+ .addJoin( "prod_orders", "product.orders" )
+ .list().get(0);
+
+ p = (Product) o[0];
+ assertTrue(Hibernate.isInitialized( p.getOrders() ));
+ assertNotNull(p.getOrders().iterator().next());
+ t.commit();
+ s.close();
+ }
+
public void testAutoDetectAliasing() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -372,6 +443,15 @@
assertTrue(m.containsKey("ENDDATE"));
assertEquals(8, m.size());
+ list = s.createSQLQuery( getEmploymentSQLMixedScalarEntity() ).addScalar( "employerid" ).addEntity( Employment.class ).list();
+ assertEquals(1, list.size());
+ o = (Object[]) list.get(0);
+ assertEquals(2, o.length);
+ assertClassAssignability( o[0].getClass(), Number.class);
+ assertClassAssignability( o[1].getClass(), Employment.class);
+
+
+
Query queryWithCollection = s.getNamedQuery("organizationEmploymentsExplicitAliases");
queryWithCollection.setLong("id", jboss.getId() );
list = queryWithCollection.list();
@@ -419,11 +499,9 @@
s.close();
}
+
+
- public void testMixedReturnsOrdering() {
-
- }
-
public static Test suite() {
return new TestSuite(GeneralTest.class);
}
|
|
From: <hib...@li...> - 2006-06-20 10:27:47
|
Author: max...@jb...
Date: 2006-06-20 06:27:37 -0400 (Tue, 20 Jun 2006)
New Revision: 10028
Modified:
trunk/HibernateExt/tools/src/templates/seam/edit.jsp.ftl
trunk/HibernateExt/tools/src/templates/seam/editorbean.java.ftl
trunk/HibernateExt/tools/src/templates/seam/faces-config.xml.ftl
trunk/HibernateExt/tools/src/templates/seam/find.jsp.ftl
trunk/HibernateExt/tools/src/templates/seam/finderbean.java.ftl
trunk/HibernateExt/tools/src/templates/seam/messages.properties.ftl
trunk/HibernateExt/tools/src/templates/seam/selector.java.ftl
Log:
pure code layout update to seam templates - no functional or visual changes
Modified: trunk/HibernateExt/tools/src/templates/seam/edit.jsp.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/seam/edit.jsp.ftl 2006-06-20 10:27:20 UTC (rev 10027)
+++ trunk/HibernateExt/tools/src/templates/seam/edit.jsp.ftl 2006-06-20 10:27:37 UTC (rev 10028)
@@ -24,9 +24,13 @@
<div class="rvgSwitch">
<h:selectOneMenu value="${'#'}{switcher.conversationIdOrOutcome}">
-<#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())> <f:selectItem itemLabel="Create ${entity.shortName}" itemValue="edit${entity.shortName}"/>
-</#foreach><#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())> <f:selectItem itemLabel="Find ${entity.shortName}" itemValue="find${entity.shortName}"/>
-</#foreach> <f:selectItems value="${'#'}{switcher.selectItems}"/>
+<#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())>
+ <f:selectItem itemLabel="Create ${entity.shortName}" itemValue="edit${entity.shortName}"/>
+</#foreach>
+<#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())>
+ <f:selectItem itemLabel="Find ${entity.shortName}" itemValue="find${entity.shortName}"/>
+</#foreach>
+ <f:selectItems value="${'#'}{switcher.selectItems}"/>
</h:selectOneMenu>
<h:commandButton action="${'#'}{switcher.select}" value="Switch"/>
</div>
@@ -37,22 +41,37 @@
<span class="rvgInputs">
<span class="rvgMessage"><h:messages globalOnly="true"/></span>
-<#foreach field in pojo.getAllPropertiesIterator()><#if !c2h.isCollection(field) && !c2h.isManyToOne(field)> <h:outputLabel value="${'#'}{msg.${pojo.shortName}_${field.name}}" for="${field.name}">
-<#if field.equals(pojo.identifierProperty)><#if field.value.identifierGeneratorStrategy == "assigned"> <h:inputText value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}" disabled="${'#'}{!${entityEditor}.new}"/>
-</#if><#else><#if field.value.typeName == "date"> <h:inputText value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}">
+<#foreach field in pojo.getAllPropertiesIterator()>
+<#if !c2h.isCollection(field) && !c2h.isManyToOne(field)>
+ <h:outputLabel value="${'#'}{msg.${pojo.shortName}_${field.name}}" for="${field.name}">
+<#if field.equals(pojo.identifierProperty)>
+<#if field.value.identifierGeneratorStrategy == "assigned">
+ <h:inputText value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}" disabled="${'#'}{!${entityEditor}.new}"/>
+</#if>
+<#else>
+<#if field.value.typeName == "date">
+ <h:inputText value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}">
<f:convertDateTime type="date" dateStyle="short"/>
</h:inputText>
-<#elseif field.value.typeName == "time"> <h:inputText value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}">
+<#elseif field.value.typeName == "time">
+ <h:inputText value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}">
<f:convertDateTime type="time"/>
</h:inputText>
-<#elseif field.value.typeName == "timestamp"> <h:inputText value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}">
+<#elseif field.value.typeName == "timestamp">
+ <h:inputText value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}">
<f:convertDateTime type="both" dateStyle="short"/>
</h:inputText>
-<#elseif field.value.typeName == "boolean"> <h:selectBooleanCheckbox value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}"/>
-<#else> <h:inputText value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}"/>
-</#if></#if> <span class="rvgMessage"><h:message for="${field.name}"/></span>
+<#elseif field.value.typeName == "boolean">
+ <h:selectBooleanCheckbox value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}"/>
+<#else>
+ <h:inputText value="${'#'}{${entityEditor}.instance.${field.name}}" id="${field.name}"/>
+</#if>
+</#if>
+ <span class="rvgMessage"><h:message for="${field.name}"/></span>
</h:outputLabel>
-</#if></#foreach> </span>
+</#if>
+</#foreach>
+ </span>
<span class="rvgActions">
<h:commandButton type="submit" value="${'#'}{msg.Create}" action="${'#'}{${entityEditor}.create}" rendered="${'#'}{${entityEditor}.new}"/>
@@ -64,22 +83,32 @@
</fieldset>
</div>
-<#foreach property in pojo.getAllPropertiesIterator()><#if c2h.isManyToOne(property)><#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))> <div class="rvgResults">
+<#foreach property in pojo.getAllPropertiesIterator()>
+<#if c2h.isManyToOne(property)>
+<#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
+ <div class="rvgResults">
<h2><h:outputText value="${'#'}{msg.${pojo.shortName}_${property.name}}"/></h2>
<h:outputText value="${'#'}{msg.No} ${'#'}{msg.${pojo.shortName}_${property.name}}" rendered="${'#'}{${entityEditor}.instance.${property.name} == null}"/>
<h:dataTable var="parent" value="${'#'}{${entityEditor}.instance.${property.name}}"
rendered="${'#'}{${entityEditor}.instance.${property.name} != null}" rowClasses="rvgRowOne,rvgRowTwo">
-<#foreach parentProperty in parentPojo.getAllPropertiesIterator()><#if !c2h.isCollection(parentProperty) && !c2h.isManyToOne(parentProperty)> <h:column>
+<#foreach parentProperty in parentPojo.getAllPropertiesIterator()>
+<#if !c2h.isCollection(parentProperty) && !c2h.isManyToOne(parentProperty)>
+ <h:column>
<f:facet name="header"><h:outputText value="${'#'}{msg.${parentPojo.shortName}_${parentProperty.name}}"/></f:facet>
<h:outputText value="${'#'}{parent.${parentProperty.name}}"/>
</h:column>
-</#if><#if c2h.isManyToOne(parentProperty)><#assign parentParentPojo = c2j.getPOJOClass(cfg.getClassMapping(parentProperty.value.referencedEntityName))> <h:column>
+</#if>
+<#if c2h.isManyToOne(parentProperty)>
+<#assign parentParentPojo = c2j.getPOJOClass(cfg.getClassMapping(parentProperty.value.referencedEntityName))>
+ <h:column>
<f:facet name="header">
<h:outputText value="${'#'}{msg.${parentPojo.shortName}_${parentProperty.name}} ${'#'}{msg.${parentParentPojo.shortName}_${parentParentPojo.identifierProperty.name}}"/>
</f:facet>
<h:outputText value="${'#'}{parent.${parentProperty.name}.${parentParentPojo.identifierProperty.name}}"/>
</h:column>
-</#if></#foreach> <h:column>
+</#if>
+</#foreach>
+ <h:column>
<f:facet name="header"><h:outputText value="${'#'}{msg.Action}"/></f:facet>
<h:commandButton action="${'#'}{${entityEditor}.${property.name}}" value="${'#'}{msg.View} ${'#'}{msg.${parentPojo.shortName}}"/>
</h:column>
@@ -91,20 +120,30 @@
</div>
-</#if><#if c2h.isOneToManyCollection(property)> <div class="rvgResults">
+</#if>
+<#if c2h.isOneToManyCollection(property)>
+ <div class="rvgResults">
<h2><h:outputText value="${'#'}{msg.${pojo.shortName}_${property.name}}"/></h2>
-<#assign childList = property.name + "List"><#assign childPojo = c2j.getPOJOClass(property.value.element.associatedClass)> <h:outputText value="${'#'}{msg.No} ${'#'}{msg.${pojo.shortName}_${property.name}}" rendered="${'#'}{${childList}.rowCount==0}"/>
+<#assign childList = property.name + "List">
+<#assign childPojo = c2j.getPOJOClass(property.value.element.associatedClass)>
+ <h:outputText value="${'#'}{msg.No} ${'#'}{msg.${pojo.shortName}_${property.name}}" rendered="${'#'}{${childList}.rowCount==0}"/>
<h:dataTable value="${'#'}{${childList}}" var="child" rendered="${'#'}{${childList}.rowCount>0}" rowClasses="rvgRowOne,rvgRowTwo">
-<#foreach childProperty in childPojo.getAllPropertiesIterator()><#if !c2h.isCollection(childProperty) && !c2h.isManyToOne(childProperty)> <h:column>
+<#foreach childProperty in childPojo.getAllPropertiesIterator()>
+<#if !c2h.isCollection(childProperty) && !c2h.isManyToOne(childProperty)>
+ <h:column>
<f:facet name="header"><h:outputText value="${'#'}{msg.${childPojo.shortName}_${childProperty.name}}"/></f:facet>
<h:outputText value="${'#'}{child.${childProperty.name}}"/>
</h:column>
-</#if></#foreach> <h:column>
+</#if>
+</#foreach>
+ <h:column>
<f:facet name="header"><h:outputText value="${'#'}{msg.Action}"/></f:facet>
<h:commandButton action="${'#'}{${entityEditor}.select${childPojo.shortName}}" value="${'#'}{msg.View} ${'#'}{msg.${childPojo.shortName}}"/>
-<#if property.value.key.nullable><!-- <h:commandButton action="${'#'}{${entityEditor}.remove${childPojo.shortName}}" value="${'#'}{msg.Remove} ${'#'}{msg.${childPojo.shortName}}"/> -->
-</#if> </h:column>
+<#if property.value.key.nullable>
+<!-- <h:commandButton action="${'#'}{${entityEditor}.remove${childPojo.shortName}}" value="${'#'}{msg.Remove} ${'#'}{msg.${childPojo.shortName}}"/> -->
+</#if>
+ </h:column>
</h:dataTable>
<span class="rvgPage">
@@ -114,7 +153,8 @@
</div>
-</#if></#foreach>
+</#if>
+</#foreach>
</h:form>
</body>
Modified: trunk/HibernateExt/tools/src/templates/seam/editorbean.java.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/seam/editorbean.java.ftl 2006-06-20 10:27:20 UTC (rev 10027)
+++ trunk/HibernateExt/tools/src/templates/seam/editorbean.java.ftl 2006-06-20 10:27:37 UTC (rev 10028)
@@ -2,7 +2,11 @@
// Generated ${date} by Hibernate Tools ${version}
<#assign classbody>
-<#assign entityEditor = pojo.shortName.toLowerCase() + "Editor"><#assign entityFinder = pojo.shortName.toLowerCase() + "Finder"><#assign entityList = pojo.shortName.toLowerCase() + "List"><#assign entity = pojo.shortName.toLowerCase()><#assign entityClass = pojo.importType(pojo.qualifiedDeclarationName)>
+<#assign entityEditor = pojo.shortName.toLowerCase() + "Editor">
+<#assign entityFinder = pojo.shortName.toLowerCase() + "Finder">
+<#assign entityList = pojo.shortName.toLowerCase() + "List">
+<#assign entity = pojo.shortName.toLowerCase()>
+<#assign entityClass = pojo.importType(pojo.qualifiedDeclarationName)>
@${pojo.importType("org.jboss.seam.annotations.Name")}("${entityEditor}")
@${pojo.importType("javax.ejb.Stateful")}
@${pojo.importType("javax.interceptor.Interceptors")}(${pojo.importType("org.jboss.seam.ejb.SeamInterceptor")}.class)
@@ -44,7 +48,8 @@
@${pojo.importType("org.jboss.seam.annotations.Begin")}(join=true)
@${pojo.importType("org.jboss.seam.annotations.IfInvalid")}(outcome=${pojo.importType("org.jboss.seam.annotations.Outcome")}.REDISPLAY)
public String create() {
-<#if pojo.identifierProperty.value.identifierGeneratorStrategy == "assigned"> if ( entityManager.find(${entityClass}.class, instance.${pojo.getGetterSignature(pojo.identifierProperty)}())!=null )
+<#if pojo.identifierProperty.value.identifierGeneratorStrategy == "assigned">
+ if ( entityManager.find(${entityClass}.class, instance.${pojo.getGetterSignature(pojo.identifierProperty)}())!=null )
{
${pojo.importType("javax.faces.context.FacesContext")}.getCurrentInstance().addMessage(null,
new ${pojo.importType("javax.faces.application.FacesMessage")}(
@@ -56,10 +61,15 @@
}
</#if> entityManager.persist(instance);
isNew = false;
-<#foreach property in pojo.getAllPropertiesIterator()><#if c2h.isManyToOne(property)><#assign getter = "get" + pojo.getPropertyName(property)> if (instance.${getter}()!=null) {
+<#foreach property in pojo.getAllPropertiesIterator()>
+ <#if c2h.isManyToOne(property)>
+ <#assign getter = "get" + pojo.getPropertyName(property)>
+ if (instance.${getter}()!=null) {
instance.${getter}().get${pojo.shortName}s().add(instance);
}
-</#if></#foreach> refreshFinder();
+ </#if>
+</#foreach>
+ refreshFinder();
return "edit${pojo.shortName}";
}
@@ -72,8 +82,13 @@
@${pojo.importType("org.jboss.seam.annotations.End")}(ifOutcome="find")
public String delete() {
entityManager.remove(instance);
-<#foreach property in pojo.getAllPropertiesIterator()><#if c2h.isManyToOne(property)><#assign getter = "get" + pojo.getPropertyName(property)> instance.${getter}().get${pojo.shortName}s().remove(instance);
-</#if></#foreach> refreshFinder();
+<#foreach property in pojo.getAllPropertiesIterator()>
+ <#if c2h.isManyToOne(property)>
+ <#assign getter = "get" + pojo.getPropertyName(property)>
+ instance.${getter}().get${pojo.shortName}s().remove(instance);
+ </#if>
+</#foreach>
+ refreshFinder();
return doneOutcome;
}
@@ -90,7 +105,11 @@
@${pojo.importType("org.jboss.seam.annotations.Destroy")} @${pojo.importType("javax.ejb.Remove")}
public void destroy() {}
-<#foreach property in pojo.getAllPropertiesIterator()><#assign getter = "get" + pojo.getPropertyName(property)><#if c2h.isManyToOne(property)><#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))><#assign parentEditor = parentPojo.shortName.toLowerCase() + "Editor">
+<#foreach property in pojo.getAllPropertiesIterator()>
+ <#assign getter = "get" + pojo.getPropertyName(property)>
+ <#if c2h.isManyToOne(property)>
+ <#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
+ <#assign parentEditor = parentPojo.shortName.toLowerCase() + "Editor">
@${pojo.importType("org.jboss.seam.annotations.In")}(create=true)
private transient ${parentPojo.shortName}Editor ${parentEditor};
@@ -101,14 +120,18 @@
return "edit${parentPojo.shortName}";
}
-<#assign entitySelector = parentPojo.shortName.toLowerCase() + "Selector"><#assign childSelector = pojo.shortName.toLowerCase() + parentPojo.shortName + "Selector"> @${pojo.importType("org.jboss.seam.annotations.Begin")}(join=true)
+<#assign entitySelector = parentPojo.shortName.toLowerCase() + "Selector"><#assign childSelector = pojo.shortName.toLowerCase() + parentPojo.shortName + "Selector">
+ @${pojo.importType("org.jboss.seam.annotations.Begin")}(join=true)
public String select${parentPojo.shortName}() {
${pojo.staticImport("org.jboss.seam.ScopeType", "CONVERSATION")}.getContext().set("${entitySelector}",
${pojo.importType("org.jboss.seam.Component")}.getInstance("${childSelector}", true) );
return "select${parentPojo.shortName}";
}
-</#if><#if c2h.isOneToManyCollection(property)><#assign childPojo = c2j.getPOJOClass(property.value.element.associatedClass)><#assign childEditor = childPojo.shortName.toLowerCase() + "Editor">
+</#if>
+<#if c2h.isOneToManyCollection(property)>
+ <#assign childPojo = c2j.getPOJOClass(property.value.element.associatedClass)>
+ <#assign childEditor = childPojo.shortName.toLowerCase() + "Editor">
@${pojo.importType("org.jboss.seam.annotations.datamodel.DataModel")}
public ${pojo.importType("java.util.List")} ${getter}List() {
return instance == null || instance.${getter}()==null ?
@@ -136,13 +159,15 @@
return "edit${childPojo.shortName}";
}
-<#if property.value.key.nullable>
+ <#if property.value.key.nullable>
/*public String remove${childPojo.shortName}() {
instance.${getter}.remove( selected${childPojo.shortName} );
selected${childPojo.shortName}.set${pojo.shortName}(null);
return "edit";
}*/
-</#if></#if></#foreach>
+ </#if>
+</#if>
+</#foreach>
}
</#assign>
Modified: trunk/HibernateExt/tools/src/templates/seam/faces-config.xml.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/seam/faces-config.xml.ftl 2006-06-20 10:27:20 UTC (rev 10027)
+++ trunk/HibernateExt/tools/src/templates/seam/faces-config.xml.ftl 2006-06-20 10:27:37 UTC (rev 10028)
@@ -4,7 +4,8 @@
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
-<#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())> <!-- navigation rules for ${entity.qualifiedDeclarationName} -->
+<#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())>
+ <!-- navigation rules for ${entity.qualifiedDeclarationName} -->
<navigation-rule>
<navigation-case>
Modified: trunk/HibernateExt/tools/src/templates/seam/find.jsp.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/seam/find.jsp.ftl 2006-06-20 10:27:20 UTC (rev 10027)
+++ trunk/HibernateExt/tools/src/templates/seam/find.jsp.ftl 2006-06-20 10:27:37 UTC (rev 10028)
@@ -4,7 +4,11 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<f:view>
<f:loadBundle basename="messages" var="msg"/>
-<#assign entityFinder = pojo.shortName.toLowerCase() + "Finder"><#assign entitySelector = pojo.shortName.toLowerCase() + "Selector"><#assign entityList = pojo.shortName.toLowerCase() + "List"><#assign entityvar = pojo.shortName.toLowerCase()> <head>
+<#assign entityFinder = pojo.shortName.toLowerCase() + "Finder">
+<#assign entitySelector = pojo.shortName.toLowerCase() + "Selector">
+<#assign entityList = pojo.shortName.toLowerCase() + "List">
+<#assign entityvar = pojo.shortName.toLowerCase()>
+ <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><h:outputText value="${'#'}{${entitySelector}.pageTitle}"/></title>
<style type="text/css" media="all">
@@ -19,9 +23,13 @@
<div class="rvgSwitch">
<h:selectOneMenu value="${'#'}{switcher.conversationIdOrOutcome}">
-<#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())> <f:selectItem itemLabel="Create ${entity.shortName}" itemValue="edit${entity.shortName}"/>
-</#foreach><#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())> <f:selectItem itemLabel="Find ${entity.shortName}" itemValue="find${entity.shortName}"/>
-</#foreach> <f:selectItems value="${'#'}{switcher.selectItems}"/>
+<#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())>
+ <f:selectItem itemLabel="Create ${entity.shortName}" itemValue="edit${entity.shortName}"/>
+</#foreach>
+<#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())>
+ <f:selectItem itemLabel="Find ${entity.shortName}" itemValue="find${entity.shortName}"/>
+</#foreach>
+ <f:selectItems value="${'#'}{switcher.selectItems}"/>
</h:selectOneMenu>
<h:commandButton action="${'#'}{switcher.select}" value="Switch"/>
</div>
@@ -31,20 +39,30 @@
<legend><h:outputText value="${'#'}{msg.${pojo.shortName}} ${'#'}{msg.SearchCriteria}"/></legend>
<span class="rvgInputs">
-<#foreach field in pojo.getAllPropertiesIterator()><#if !c2h.isCollection(field) && !c2h.isManyToOne(field)> <h:outputLabel value="${'#'}{msg.${pojo.shortName}_${field.name}}" for="${field.name}">
-<#if field.value.typeName == "date"> <h:inputText value="${'#'}{${entityFinder}.example.${field.name}}" id="${field.name}">
+<#foreach field in pojo.getAllPropertiesIterator()>
+<#if !c2h.isCollection(field) && !c2h.isManyToOne(field)>
+ <h:outputLabel value="${'#'}{msg.${pojo.shortName}_${field.name}}" for="${field.name}">
+<#if field.value.typeName == "date">
+ <h:inputText value="${'#'}{${entityFinder}.example.${field.name}}" id="${field.name}">
<f:convertDateTime type="date" dateStyle="short"/>
</h:inputText>
-<#elseif field.value.typeName == "time"> <h:inputText value="${'#'}{${entityFinder}.example.${field.name}}" id="${field.name}">
+<#elseif field.value.typeName == "time">
+ <h:inputText value="${'#'}{${entityFinder}.example.${field.name}}" id="${field.name}">
<f:convertDateTime type="time"/>
</h:inputText>
-<#elseif field.value.typeName == "timestamp"> <h:inputText value="${'#'}{${entityFinder}.example.${field.name}}" id="${field.name}">
+<#elseif field.value.typeName == "timestamp">
+ <h:inputText value="${'#'}{${entityFinder}.example.${field.name}}" id="${field.name}">
<f:convertDateTime type="both" dateStyle="short"/>
</h:inputText>
-<#elseif field.value.typeName == "boolean"> <h:selectBooleanCheckbox value="${'#'}{${entityFinder}.example.${field.name}}" id="${field.name}"/>
-<#else> <h:inputText value="${'#'}{${entityFinder}.example.${field.name}}" id="${field.name}"/>
-</#if> </h:outputLabel>
-</#if></#foreach> <h:outputLabel value="${'#'}{msg.PageSize}" for="pageSize">
+<#elseif field.value.typeName == "boolean">
+ <h:selectBooleanCheckbox value="${'#'}{${entityFinder}.example.${field.name}}" id="${field.name}"/>
+<#else>
+ <h:inputText value="${'#'}{${entityFinder}.example.${field.name}}" id="${field.name}"/>
+</#if>
+ </h:outputLabel>
+</#if>
+</#foreach>
+ <h:outputLabel value="${'#'}{msg.PageSize}" for="pageSize">
<h:inputText value="${'#'}{${entityFinder}.pageSize}" id="pageSize"/>
</h:outputLabel>
</span>
@@ -66,7 +84,9 @@
<h:dataTable value="${'#'}{${entityList}}" var="${entityvar}" rendered="${'#'}{${entityList}.rowCount>0}"
rowClasses="rvgRowOne,rvgRowTwo" headerClass="rvgOrder">
-<#foreach property in pojo.getAllPropertiesIterator()><#if !c2h.isCollection(property) && !c2h.isManyToOne(property)> <h:column>
+<#foreach property in pojo.getAllPropertiesIterator()>
+<#if !c2h.isCollection(property) && !c2h.isManyToOne(property)>
+ <h:column>
<f:facet name="header">
<h:commandLink value="${'#'}{msg.${pojo.shortName}_${property.name}}" action="${'#'}{${entityFinder}.reorder}">
<f:param name="orderBy" value="${property.name}"/>
@@ -74,13 +94,18 @@
</f:facet>
<h:outputText value="${'#'}{${entityvar}.${property.name}}"/>
</h:column>
-</#if><#if c2h.isManyToOne(property)><#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))> <h:column>
+</#if>
+<#if c2h.isManyToOne(property)>
+<#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
+ <h:column>
<f:facet name="header">
<h:outputText value="${'#'}{msg.${pojo.shortName}_${property.name}} ${'#'}{msg.${parentPojo.shortName}_${parentPojo.identifierProperty.name}}"/>
</f:facet>
<h:outputText value="${'#'}{${entityvar}.${property.name}.${parentPojo.identifierProperty.name}}"/>
</h:column>
-</#if></#foreach> <h:column>
+</#if>
+</#foreach>
+ <h:column>
<f:facet name="header"><h:outputText value="${'#'}{msg.Action}"/></f:facet>
<h:commandButton action="${'#'}{${entitySelector}.select}" value="${'#'}{${entitySelector}.buttonLabel}"/>
</h:column>
@@ -98,7 +123,6 @@
</h:form>
-
</body>
</f:view>
</html>
\ No newline at end of file
Modified: trunk/HibernateExt/tools/src/templates/seam/finderbean.java.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/seam/finderbean.java.ftl 2006-06-20 10:27:20 UTC (rev 10027)
+++ trunk/HibernateExt/tools/src/templates/seam/finderbean.java.ftl 2006-06-20 10:27:37 UTC (rev 10028)
@@ -2,7 +2,10 @@
// Generated ${date} by Hibernate Tools ${version}
<#assign classbody>
-<#assign entityFinder = pojo.shortName.toLowerCase() + "Finder"><#assign entityList = pojo.shortName.toLowerCase() + "List"><#assign entityvar = pojo.shortName.toLowerCase()><#assign entityClass = pojo.importType(pojo.qualifiedDeclarationName)>
+<#assign entityFinder = pojo.shortName.toLowerCase() + "Finder">
+<#assign entityList = pojo.shortName.toLowerCase() + "List">
+<#assign entityvar = pojo.shortName.toLowerCase()>
+<#assign entityClass = pojo.importType(pojo.qualifiedDeclarationName)>
@${pojo.importType("org.jboss.seam.annotations.Name")}("${entityFinder}")
@${pojo.importType("javax.ejb.Stateful")}
@${pojo.importType("org.jboss.seam.annotations.Scope")}(${pojo.importType("org.jboss.seam.ScopeType")}.SESSION)
@@ -43,25 +46,33 @@
${pojo.importType("java.util.Map")}<String, Object> parameters = new ${pojo.importType("java.util.HashMap")}<String, Object>();
StringBuffer queryString = new StringBuffer();
<#foreach property in pojo.getAllPropertiesIterator()>
-<#assign valueMethod = pojo.getGetterSignature(property) + "()"><#assign type = c2j.getJavaTypeName(property, true)><#if type == "java.lang.String"> if ( example.${valueMethod} != null && example.${valueMethod}.length() > 0 ) {
+<#assign valueMethod = pojo.getGetterSignature(property) + "()">
+<#assign type = c2j.getJavaTypeName(property, true)>
+<#if type == "java.lang.String">
+ if ( example.${valueMethod} != null && example.${valueMethod}.length() > 0 ) {
queryString.append(" and ${entityvar}.${property.name} like :${property.name}");
parameters.put( "${property.name}", '%' + example.${valueMethod} + '%' );
}
-<#elseif type == "boolean"> queryString.append(" and ${entityvar}.${property.name} = :${property.name}");
+<#elseif type == "boolean">
+ queryString.append(" and ${entityvar}.${property.name} = :${property.name}");
parameters.put( "${property.name}", example.${valueMethod} );
-<#elseif type == "long" || type == "int" || type == "short" || type == "byte"> if ( example.${valueMethod} != 0 ) {
+<#elseif type == "long" || type == "int" || type == "short" || type == "byte">
+ if ( example.${valueMethod} != 0 ) {
queryString.append(" and ${entityvar}.${property.name} = :${property.name}");
parameters.put( "${property.name}", example.${valueMethod} );
}
-<#elseif type == "float" || type == "double"> if ( example.${valueMethod} != 0.0 ) {
+<#elseif type == "float" || type == "double">
+ if ( example.${valueMethod} != 0.0 ) {
queryString.append(" and ${entityvar}.${property.name} = :${property.name}");
parameters.put( "${property.name}", example.${valueMethod} );
}
-<#elseif !c2h.isCollection(property) && !c2h.isManyToOne(property)> if ( example.${valueMethod} != null ) {
+<#elseif !c2h.isCollection(property) && !c2h.isManyToOne(property)>
+ if ( example.${valueMethod} != null ) {
queryString.append(" and ${entityvar}.${property.name} = :${property.name}");
parameters.put( "${property.name}", example.${valueMethod} );
}
-</#if></#foreach>
+</#if>
+</#foreach>
if ( queryString.length()==0 ) {
queryString.append("select ${entityvar} from ${pojo.shortName} ${entityvar}");
}
Modified: trunk/HibernateExt/tools/src/templates/seam/messages.properties.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/seam/messages.properties.ftl 2006-06-20 10:27:20 UTC (rev 10027)
+++ trunk/HibernateExt/tools/src/templates/seam/messages.properties.ftl 2006-06-20 10:27:37 UTC (rev 10028)
@@ -21,6 +21,9 @@
PageSize=results per page
AlreadyExists=already exists
-<#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())>${entity.shortName}=${entity.shortName}
-<#foreach property in entity.getAllPropertiesIterator()>${entity.shortName}_${property.name}=${property.name}
-</#foreach></#foreach>
\ No newline at end of file
+<#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())>
+${entity.shortName}=${entity.shortName}
+<#foreach property in entity.getAllPropertiesIterator()>
+${entity.shortName}_${property.name}=${property.name}
+</#foreach>
+</#foreach>
\ No newline at end of file
Modified: trunk/HibernateExt/tools/src/templates/seam/selector.java.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/seam/selector.java.ftl 2006-06-20 10:27:20 UTC (rev 10027)
+++ trunk/HibernateExt/tools/src/templates/seam/selector.java.ftl 2006-06-20 10:27:37 UTC (rev 10028)
@@ -15,7 +15,10 @@
public boolean isCreateEnabled();
-<#assign entityEditor = pojo.shortName.toLowerCase() + "Editor"><#assign entitySelector = pojo.shortName.toLowerCase() + "Selector"><#assign entityFinder = pojo.shortName.toLowerCase() + "Finder"> @${pojo.importType("javax.ejb.Stateless")}
+<#assign entityEditor = pojo.shortName.toLowerCase() + "Editor">
+<#assign entitySelector = pojo.shortName.toLowerCase() + "Selector">
+<#assign entityFinder = pojo.shortName.toLowerCase() + "Finder">
+ @${pojo.importType("javax.ejb.Stateless")}
@${pojo.importType("org.jboss.seam.annotations.Name")}("${entitySelector}")
@${pojo.importType("javax.interceptor.Interceptors")}(${pojo.importType("org.jboss.seam.ejb.SeamInterceptor")}.class)
public static class Default${pojo.shortName}Selector implements ${pojo.shortName}Selector {
@@ -59,7 +62,12 @@
}
-<#foreach property in pojo.getAllPropertiesIterator()><#if c2h.isOneToManyCollection(property)><#assign childPojo = c2j.getPOJOClass(property.value.element.associatedClass)><#assign childEditor = childPojo.shortName.toLowerCase() + "Editor"><#assign childSelector = childPojo.shortName.toLowerCase() + pojo.shortName + "Selector"> @${pojo.importType("javax.ejb.Stateless")}
+<#foreach property in pojo.getAllPropertiesIterator()>
+<#if c2h.isOneToManyCollection(property)>
+<#assign childPojo = c2j.getPOJOClass(property.value.element.associatedClass)>
+<#assign childEditor = childPojo.shortName.toLowerCase() + "Editor">
+<#assign childSelector = childPojo.shortName.toLowerCase() + pojo.shortName + "Selector">
+ @${pojo.importType("javax.ejb.Stateless")}
@${pojo.importType("org.jboss.seam.annotations.Name")}("${childSelector}")
@${pojo.importType("org.jboss.annotation.ejb.LocalBinding")}(jndiBinding="${childPojo.qualifiedDeclarationName}${pojo.shortName}Selector")
@${pojo.importType("org.jboss.seam.annotations.JndiName")}("${childPojo.qualifiedDeclarationName}${pojo.shortName}Selector")
@@ -114,7 +122,8 @@
}
-</#if></#foreach>}
+</#if>
+</#foreach>}
</#assign>
${pojo.generateImports()}
|
|
From: <hib...@li...> - 2006-06-20 10:27:25
|
Author: max...@jb...
Date: 2006-06-20 06:27:20 -0400 (Tue, 20 Jun 2006)
New Revision: 10027
Modified:
trunk/HibernateExt/tools/src/java/org/hibernate/tool/ide/completion/ConfigurationCompletion.java
Log:
workaround annotations bug regarding missing entitynames in imports
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/tool/ide/completion/ConfigurationCompletion.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/ide/completion/ConfigurationCompletion.java 2006-06-20 10:26:14 UTC (rev 10026)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/tool/ide/completion/ConfigurationCompletion.java 2006-06-20 10:27:20 UTC (rev 10027)
@@ -209,7 +209,7 @@
if(path==null) return null;
String entityName = (String) cfg.getImports().get( path );
if(entityName==null) {
- return null;
+ return cfg.getClassMapping( path ); // annotationconfiguration does not put full imports into imports.
} else {
return cfg.getClassMapping( entityName );
}
|
|
From: <hib...@li...> - 2006-06-20 10:26:24
|
Author: max...@jb... Date: 2006-06-20 06:26:14 -0400 (Tue, 20 Jun 2006) New Revision: 10026 Modified: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java Log: doc typos Modified: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java =================================================================== --- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java 2006-06-19 03:32:09 UTC (rev 10025) +++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java 2006-06-20 10:26:14 UTC (rev 10026) @@ -44,10 +44,10 @@ */ public String columnToPropertyName(TableIdentifier table, String column); - /** Should this foreignkey be used as a oneToMany */ + /** 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 used as a many-to-one */ + /** 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 ? */ |
|
From: <hib...@li...> - 2006-06-19 03:32:12
|
Author: epbernard
Date: 2006-06-18 23:32:09 -0400 (Sun, 18 Jun 2006)
New Revision: 10025
Modified:
trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
Log:
ANN-336
Modified: trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2006-06-16 02:49:06 UTC (rev 10024)
+++ trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2006-06-19 03:32:09 UTC (rev 10025)
@@ -710,6 +710,83 @@
return orderByString;
}
+ private static String buildOrderByClauseFromHql(String hqlOrderBy, Component component, String role) {
+ String orderByString = null;
+ if ( hqlOrderBy != null ) {
+ List<String> properties = new ArrayList<String>();
+ List<String> ordering = new ArrayList<String>();
+ StringBuilder orderByBuffer = new StringBuilder();
+ if ( "".equals( hqlOrderBy ) ) {
+ //TODO : Check that. Maybe order by key for maps
+ }
+ else {
+ StringTokenizer st = new StringTokenizer( hqlOrderBy, " ,", false );
+ String currentOrdering = null;
+ //FIXME make this code decent
+ while ( st.hasMoreTokens() ) {
+ String token = st.nextToken();
+ if ( isNonPropertyToken( token ) ) {
+ if ( currentOrdering != null ) {
+ throw new AnnotationException(
+ "Error while parsing HQL orderBy clause: " + hqlOrderBy
+ + " (" + role + ")"
+ );
+ }
+ currentOrdering = token;
+ }
+ else {
+ //Add ordering of the previous
+ if ( currentOrdering == null ) {
+ //default ordering
+ ordering.add( "asc" );
+ }
+ else {
+ ordering.add( currentOrdering );
+ currentOrdering = null;
+ }
+ properties.add( token );
+ }
+ }
+ ordering.remove( 0 ); //first one is the algorithm starter
+ // add last one ordering
+ if ( currentOrdering == null ) {
+ //default ordering
+ ordering.add( "asc" );
+ }
+ else {
+ ordering.add( currentOrdering );
+ currentOrdering = null;
+ }
+ int index = 0;
+
+ for ( String property : properties ) {
+ Property p = component.getProperty( property );
+ if ( p == null ) {
+ throw new AnnotationException(
+ "property from @OrderBy clause not found: "
+ + role + "." + property
+ );
+ }
+
+ Iterator propertyColumns = p.getColumnIterator();
+ while ( propertyColumns.hasNext() ) {
+ Column column = (Column) propertyColumns.next();
+ orderByBuffer.append( column.getName() )
+ .append( " " )
+ .append( ordering.get( index ) )
+ .append( ", " );
+ }
+ index++;
+ }
+
+ if ( orderByBuffer.length() >= 2 ) {
+ orderByString = orderByBuffer.substring( 0, orderByBuffer.length() - 2 );
+ }
+ }
+ }
+ return orderByString;
+ }
+
private static boolean isNonPropertyToken(String token) {
if ( " ".equals( token ) ) return true;
if ( ",".equals( token ) ) return true;
@@ -803,16 +880,7 @@
}
}
}
- if ( StringHelper.isNotEmpty( hqlOrderBy ) ) {
- if ( ! isCollectionOfEntities ) {
- collValue.setOrderBy( hqlOrderBy );
- }
- else {
- collValue.setManyToManyOrdering(
- buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() )
- );
- }
- }
+
boolean mappedBy = ! AnnotationBinder.isDefault( joinColumns[0].getMappedBy() );
if ( mappedBy ) {
if ( ! isCollectionOfEntities ) {
@@ -897,6 +965,11 @@
element.setFetchMode( FetchMode.JOIN );
element.setLazy( false );
element.setIgnoreNotFound( ignoreNotFound );
+ if ( StringHelper.isNotEmpty( hqlOrderBy ) ) {
+ collValue.setManyToManyOrdering(
+ buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() )
+ );
+ }
}
else {
XClass elementClass;
@@ -960,7 +1033,16 @@
entityBinder, false, false,
mappings
);
+
collValue.setElement( component );
+
+ if ( StringHelper.isNotEmpty( hqlOrderBy ) ) {
+ String path = collValue.getOwnerEntityName() + "." + joinColumns[0].getPropertyName();
+ String orderBy = buildOrderByClauseFromHql( hqlOrderBy, component, path );
+ if ( orderBy != null ) {
+ collValue.setOrderBy( orderBy );
+ }
+ }
}
else {
SimpleValueBinder elementBinder = new SimpleValueBinder();
|
|
From: <hib...@li...> - 2006-06-16 02:49:09
|
Author: epbernard
Date: 2006-06-15 22:49:06 -0400 (Thu, 15 Jun 2006)
New Revision: 10024
Modified:
trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java
Log:
EJB-181 white space handling
Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java
===================================================================
--- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java 2006-06-15 19:57:42 UTC (rev 10023)
+++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java 2006-06-16 02:49:06 UTC (rev 10024)
@@ -6,6 +6,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
+import java.net.URISyntaxException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -26,7 +27,13 @@
protected void doProcessElements() throws IOException {
File jarFile;
- jarFile = new File( jarUrl.getFile() );
+ try {
+ jarFile = new File( jarUrl.toURI().getPath() );
+ }
+ catch (URISyntaxException e) {
+ log.warn( "Malformed url: " + jarUrl, e );
+ return;
+ }
if ( !jarFile.exists() ) {
log.warn( "Exploded jar does not exists (ignored): " + jarUrl );
return;
|
|
From: <hib...@li...> - 2006-06-15 19:58:01
|
Author: ste...@jb...
Date: 2006-06-15 15:57:42 -0400 (Thu, 15 Jun 2006)
New Revision: 10023
Modified:
branches/Branch_3_1/Hibernate3/src/org/hibernate/hql/ast/QueryTranslatorImpl.java
Log:
opened up for subclassing
Modified: branches/Branch_3_1/Hibernate3/src/org/hibernate/hql/ast/QueryTranslatorImpl.java
===================================================================
--- branches/Branch_3_1/Hibernate3/src/org/hibernate/hql/ast/QueryTranslatorImpl.java 2006-06-15 19:41:25 UTC (rev 10022)
+++ branches/Branch_3_1/Hibernate3/src/org/hibernate/hql/ast/QueryTranslatorImpl.java 2006-06-15 19:57:42 UTC (rev 10023)
@@ -33,7 +33,6 @@
import org.hibernate.persister.entity.Queryable;
import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
-import org.hibernate.util.ArrayHelper;
import java.util.HashMap;
import java.util.Iterator;
@@ -44,9 +43,6 @@
/**
* A QueryTranslator that uses an AST based parser.
- * <br>User: josh
- * <br>Date: Dec 31, 2003
- * <br>Time: 7:50:35 AM
*
* @author Joshua Davis (pg...@so...)
*/
@@ -54,6 +50,8 @@
private static final Log log = LogFactory.getLog( QueryTranslatorImpl.class );
private static final Log AST_LOG = LogFactory.getLog( "org.hibernate.hql.ast.AST" );
+ private static final String HQL_AST_HEADER = "--- HQL AST ---";
+ private static final String SQL_AST_HEADER = "--- SQL AST ---";
private SessionFactoryImplementor factory;
@@ -197,59 +195,72 @@
this.enabledFilters = null; //only needed during compilation phase...
}
- private void generate(AST sqlAst) throws QueryException, RecognitionException {
- if ( sql == null ) {
- SqlGenerator gen = new SqlGenerator(factory);
- gen.statement( sqlAst );
- sql = gen.getSQL();
- if ( log.isDebugEnabled() ) {
- log.debug( "HQL: " + hql );
- log.debug( "SQL: " + sql );
- }
- gen.getParseErrorHandler().throwQueryException();
+ protected HqlParser parse(boolean filter) throws TokenStreamException, RecognitionException {
+ // Parse the query string into an HQL AST.
+ HqlParser parser = constructHqlParserInstance();
+ parser.setFilter( filter );
+
+ if ( log.isDebugEnabled() ) {
+ log.debug( "parse() - HQL: " + hql );
}
+ parser.statement();
+
+ AST hqlAst = parser.getAST();
+
+ showHqlAst( hqlAst );
+
+ parser.getParseErrorHandler().throwQueryException();
+ return parser;
}
- private HqlSqlWalker analyze(HqlParser parser, String collectionRole) throws QueryException, RecognitionException {
- HqlSqlWalker w = new HqlSqlWalker( this, factory, parser, tokenReplacements, collectionRole );
+ protected HqlParser constructHqlParserInstance() {
+ return HqlParser.getInstance( hql );
+ }
+
+ protected HqlSqlWalker analyze(HqlParser parser, String collectionRole) throws QueryException, RecognitionException {
+ HqlSqlWalker w = constructWalkerInstance( parser, collectionRole );
AST hqlAst = parser.getAST();
// Transform the tree.
w.statement( hqlAst );
- if ( AST_LOG.isDebugEnabled() ) {
- ASTPrinter printer = new ASTPrinter( SqlTokenTypes.class );
- AST_LOG.debug( printer.showAsString( w.getAST(), "--- SQL AST ---" ) );
- }
+ showAst( SQL_AST_HEADER, w.getAST(), SqlTokenTypes.class, true );
w.getParseErrorHandler().throwQueryException();
return w;
}
- private HqlParser parse(boolean filter) throws TokenStreamException, RecognitionException {
- // Parse the query string into an HQL AST.
- HqlParser parser = HqlParser.getInstance( hql );
- parser.setFilter( filter );
+ protected HqlSqlWalker constructWalkerInstance(HqlParser parser, String collectionRole) {
+ return new HqlSqlWalker( this, factory, parser, tokenReplacements, collectionRole );
+ }
- if ( log.isDebugEnabled() ) {
- log.debug( "parse() - HQL: " + hql );
+ protected void generate(AST sqlAst) throws QueryException, RecognitionException {
+ if ( sql == null ) {
+ SqlGenerator gen = constructSqlGeneratorInstance();
+ gen.statement( sqlAst );
+ sql = gen.getSQL();
+ if ( log.isDebugEnabled() ) {
+ log.debug( "HQL: " + hql );
+ log.debug( "SQL: " + sql );
+ }
+ gen.getParseErrorHandler().throwQueryException();
}
- parser.statement();
+ }
- AST hqlAst = parser.getAST();
+ protected SqlGenerator constructSqlGeneratorInstance() {
+ return new SqlGenerator( factory );
+ }
- showHqlAst( hqlAst );
-
- parser.getParseErrorHandler().throwQueryException();
- return parser;
+ protected void showHqlAst(AST hqlAst) {
+ showAst( HQL_AST_HEADER, hqlAst, HqlTokenTypes.class, false );
}
- void showHqlAst(AST hqlAst) {
+ protected void showAst(String header, AST ast, Class tokenTypesClass, boolean showNodeClassNames) {
if ( AST_LOG.isDebugEnabled() ) {
- ASTPrinter printer = new ASTPrinter( HqlTokenTypes.class );
- printer.setShowClassNames( false ); // The class names aren't interesting in the first tree.
- AST_LOG.debug( printer.showAsString( hqlAst, "--- HQL AST ---" ) );
+ ASTPrinter printer = new ASTPrinter( tokenTypesClass );
+ printer.setShowClassNames( showNodeClassNames );
+ AST_LOG.debug( printer.showAsString( ast, header ) );
}
}
|
|
From: <hib...@li...> - 2006-06-15 19:41:44
|
Author: ste...@jb...
Date: 2006-06-15 15:41:25 -0400 (Thu, 15 Jun 2006)
New Revision: 10022
Modified:
trunk/Hibernate3/src/org/hibernate/engine/BatchFetchQueue.java
Log:
javadocs
Modified: trunk/Hibernate3/src/org/hibernate/engine/BatchFetchQueue.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/BatchFetchQueue.java 2006-06-15 19:07:03 UTC (rev 10021)
+++ trunk/Hibernate3/src/org/hibernate/engine/BatchFetchQueue.java 2006-06-15 19:41:25 UTC (rev 10022)
@@ -23,49 +23,70 @@
*/
public class BatchFetchQueue {
- public static final Object MARKER = new MarkerObject("MARKER");
+ public static final Object MARKER = new MarkerObject( "MARKER" );
- // A set of entity keys that we predict we might need to load soon
- // TODO: this would be better as a SequencedReferenceSet, but no such beast exists!
- private final Map batchLoadableEntityKeys = new SequencedHashMap(8); //actually, a Set
+ /**
+ * Defines a sequence of {@link EntityKey} elements that are currently
+ * elegible for batch-fetching.
+ * <p/>
+ * Even though this is a map, we only use the keys. A map was chosen in
+ * order to utilize a {@link SequencedHashMap} to maintain sequencing
+ * as well as uniqueness.
+ * <p/>
+ * TODO : this would be better as a SequencedReferenceSet, but no such beast exists!
+ */
+ private final Map batchLoadableEntityKeys = new SequencedHashMap(8);
- // The subqueries that were used to load the entity with the given key
- private final Map subselectsByEntityKey = new HashMap(8); //new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
+ /**
+ * A map of {@link SubselectFetch subselect-fetch descriptors} keyed by the
+ * {@link EntityKey) against which the descriptor is registered.
+ */
+ private final Map subselectsByEntityKey = new HashMap(8);
- // The owning persistence context
+ /**
+ * The owning persistence context.
+ */
private final PersistenceContext context;
+ /**
+ * Constructs a queue for the given context.
+ *
+ * @param context The owning context.
+ */
public BatchFetchQueue(PersistenceContext context) {
this.context = context;
}
+ /**
+ * Clears all entries from this fetch queue.
+ */
public void clear() {
batchLoadableEntityKeys.clear();
subselectsByEntityKey.clear();
}
+ /**
+ * Retrieve the fetch descriptor associated with the given entity key.
+ *
+ * @param key The entity key for which to locate any defined subselect fetch.
+ * @return The fetch descriptor; may return null if no subselect fetch queued for
+ * this entity key.
+ */
public SubselectFetch getSubselect(EntityKey key) {
return (SubselectFetch) subselectsByEntityKey.get(key);
}
+ /**
+ * Adds a subselect fetch decriptor for the given entity key.
+ *
+ * @param key The entity for which to register the subselect fetch.
+ * @param subquery The fetch descriptor.
+ */
public void addSubselect(EntityKey key, SubselectFetch subquery) {
subselectsByEntityKey.put(key, subquery);
}
- public void clearSubselects() {
- subselectsByEntityKey.clear();
- }
-
/**
- * After evicting or deleting or loading an entity, we don't
- * need to batch fetch it anymore, remove it from the queue
- * if necessary
- */
- public void removeBatchLoadableEntityKey(EntityKey key) {
- if ( key.isBatchLoadable() ) batchLoadableEntityKeys.remove(key);
- }
-
- /**
* After evicting or deleting an entity, we don't need to
* know the query that was used to load it anymore (don't
* call this after loading the entity, since we might still
@@ -76,14 +97,40 @@
}
/**
+ * Clears all pending subselect fetches from the queue.
+ * <p/>
+ * Called after flushing.
+ */
+ public void clearSubselects() {
+ subselectsByEntityKey.clear();
+ }
+
+ /**
* If an EntityKey represents a batch loadable entity, add
* it to the queue.
+ * <p/>
+ * Note that the contract here is such that any key passed in should
+ * previously have been been checked for existence within the
+ * {@link PersistenceContext}; failure to do so may cause the
+ * referenced entity to be included in a batch even though it is
+ * already associated with the {@link PersistenceContext}.
*/
public void addBatchLoadableEntityKey(EntityKey key) {
- if ( key.isBatchLoadable() ) batchLoadableEntityKeys.put(key, MARKER);
+ if ( key.isBatchLoadable() ) {
+ batchLoadableEntityKeys.put( key, MARKER );
+ }
}
/**
+ * After evicting or deleting or loading an entity, we don't
+ * need to batch fetch it anymore, remove it from the queue
+ * if necessary
+ */
+ public void removeBatchLoadableEntityKey(EntityKey key) {
+ if ( key.isBatchLoadable() ) batchLoadableEntityKeys.remove(key);
+ }
+
+ /**
* Get a batch of uninitialized collection keys for a given role
*
* @param collectionPersister The persister for the collection role.
|
|
From: <hib...@li...> - 2006-06-15 19:07:14
|
Author: epbernard
Date: 2006-06-15 15:07:03 -0400 (Thu, 15 Jun 2006)
New Revision: 10021
Added:
trunk/HibernateExt/metadata/src/test/org/hibernate/lucene/
Modified:
trunk/HibernateExt/metadata/src/java/org/hibernate/validator/EmailValidator.java
trunk/HibernateExt/metadata/src/test/org/hibernate/validator/test/EmailTest.java
Log:
ANN-375 fix email chacking compliant with RFC
Modified: trunk/HibernateExt/metadata/src/java/org/hibernate/validator/EmailValidator.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/validator/EmailValidator.java 2006-06-15 16:38:03 UTC (rev 10020)
+++ trunk/HibernateExt/metadata/src/java/org/hibernate/validator/EmailValidator.java 2006-06-15 19:07:03 UTC (rev 10021)
@@ -10,6 +10,9 @@
* @author Emmanuel Bernard
*/
public class EmailValidator implements Validator<Email>, Serializable {
+ private static String ATOM = "[^\\x00-\\x1F^\\(^\\)^\\<^\\>^\\@^\\,^\\(;^\\:^\\\\^\\\"^\\.^\\[^\\]^\\s]";
+ private static String DOMAIN = "(" + ATOM + "+(\\." + ATOM + "+)*";
+ private static String IP_DOMAIN = "\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\]";
private java.util.regex.Pattern pattern;
@@ -26,5 +29,13 @@
"^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*$",
java.util.regex.Pattern.CASE_INSENSITIVE
);
+ pattern = java.util.regex.Pattern.compile(
+ "^" + ATOM + "+(\\." + ATOM + "+)*@"
+ + DOMAIN
+ + "|"
+ + IP_DOMAIN
+ + ")$",
+ java.util.regex.Pattern.CASE_INSENSITIVE
+ );
}
}
Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/validator/test/EmailTest.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/validator/test/EmailTest.java 2006-06-15 16:38:03 UTC (rev 10020)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/validator/test/EmailTest.java 2006-06-15 19:07:03 UTC (rev 10021)
@@ -17,7 +17,13 @@
isRightEmail( "emmanuel@hibernate" );
isRightEmail( "emma-n_uel@hibernate" );
isWrongEmail( "emma nu...@hi..." );
+ isWrongEmail( "emma(nu...@hi..." );
isWrongEmail( "emmanuel@" );
+ isRightEmail( "emm...@hi..." );
+ isRightEmail( "emm...@hi..." );
+ isWrongEmail( "emma\nn...@hi..." );
+ isWrongEmail( "emma@nu...@hi..." );
+ isRightEmail( "emmanuel@[123.12.2.11]" );
}
private void isRightEmail(String email) {
|
|
From: <hib...@li...> - 2006-06-15 16:38:21
|
Author: ste...@jb...
Date: 2006-06-15 12:38:03 -0400 (Thu, 15 Jun 2006)
New Revision: 10020
Modified:
trunk/Hibernate3/src/org/hibernate/type/ManyToOneType.java
Log:
HHH-1831 : be careful about ManyToOneType adding entity keys to the batch fetch queue
Modified: trunk/Hibernate3/src/org/hibernate/type/ManyToOneType.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/type/ManyToOneType.java 2006-06-15 07:50:12 UTC (rev 10019)
+++ trunk/Hibernate3/src/org/hibernate/type/ManyToOneType.java 2006-06-15 16:38:03 UTC (rev 10020)
@@ -17,104 +17,110 @@
import org.hibernate.persister.entity.EntityPersister;
/**
- * A many-to-one association to an entity
+ * A many-to-one association to an entity.
+ *
* @author Gavin King
*/
public class ManyToOneType extends EntityType {
private final boolean ignoreNotFound;
-
- protected boolean isNullable() {
- return ignoreNotFound;
- }
-
- /**
- * If we have <tt>not-found="ignore"</tt> association
- * mapped to a formula, we always need to dirty check
- * it, so we can update the second-level cache
- */
- public boolean isAlwaysDirtyChecked() {
- return ignoreNotFound;
- }
-
- public int getColumnSpan(Mapping mapping) throws MappingException {
- return getIdentifierOrUniqueKeyType(mapping).getColumnSpan(mapping);
- }
- public int[] sqlTypes(Mapping mapping) throws MappingException {
- return getIdentifierOrUniqueKeyType(mapping).sqlTypes(mapping);
+ public ManyToOneType(String className) {
+ this( className, false );
}
- public ManyToOneType(String className) {
- this(className, false);
- }
-
public ManyToOneType(String className, boolean lazy) {
- super(className, null, !lazy, true, false);
+ super( className, null, !lazy, true, false );
this.ignoreNotFound = false;
}
public ManyToOneType(
- String entityName,
+ String entityName,
String uniqueKeyPropertyName,
boolean lazy,
- boolean unwrapProxy,
+ boolean unwrapProxy,
boolean isEmbeddedInXML,
- boolean ignoreNotFound
- ) {
- super(entityName, uniqueKeyPropertyName, !lazy, isEmbeddedInXML, unwrapProxy);
+ boolean ignoreNotFound) {
+ super( entityName, uniqueKeyPropertyName, !lazy, isEmbeddedInXML, unwrapProxy );
this.ignoreNotFound = ignoreNotFound;
}
- public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session)
- throws HibernateException, SQLException {
- getIdentifierOrUniqueKeyType( session.getFactory() )
- .nullSafeSet(st, getIdentifier(value, session), index, settable, session);
+ protected boolean isNullable() {
+ return ignoreNotFound;
}
- public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
- throws HibernateException, SQLException {
- getIdentifierOrUniqueKeyType( session.getFactory() )
- .nullSafeSet(st, getIdentifier(value, session), index, session);
+ public boolean isAlwaysDirtyChecked() {
+ // If we have <tt>not-found="ignore"</tt> association mapped to a
+ // formula, we always need to dirty check it, so we can update the
+ // second-level cache
+ return ignoreNotFound;
}
public boolean isOneToOne() {
return false;
}
+
+ public int getColumnSpan(Mapping mapping) throws MappingException {
+ // our column span is the number of columns in the PK
+ return getIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping );
+ }
+ public int[] sqlTypes(Mapping mapping) throws MappingException {
+ return getIdentifierOrUniqueKeyType( mapping ).sqlTypes( mapping );
+ }
+
+ public void nullSafeSet(
+ PreparedStatement st,
+ Object value,
+ int index,
+ boolean[] settable,
+ SessionImplementor session) throws HibernateException, SQLException {
+ getIdentifierOrUniqueKeyType( session.getFactory() )
+ .nullSafeSet( st, getIdentifier( value, session ), index, settable, session );
+ }
+
+ public void nullSafeSet(
+ PreparedStatement st,
+ Object value,
+ int index,
+ SessionImplementor session) throws HibernateException, SQLException {
+ getIdentifierOrUniqueKeyType( session.getFactory() )
+ .nullSafeSet( st, getIdentifier( value, session ), index, session );
+ }
+
public ForeignKeyDirection getForeignKeyDirection() {
return ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT;
}
- public Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)
- throws HibernateException, SQLException {
-
- //return the (fully resolved) identifier value, but do not resolve
- //to the actual referenced entity instance
-
+ public Object hydrate(
+ ResultSet rs,
+ String[] names,
+ SessionImplementor session,
+ Object owner) throws HibernateException, SQLException {
+ // return the (fully resolved) identifier value, but do not resolve
+ // to the actual referenced entity instance
+ // NOTE: the owner of the association is not really the owner of the id!
Serializable id = (Serializable) getIdentifierOrUniqueKeyType( session.getFactory() )
- .nullSafeGet(rs, names, session, null); //note that the owner of the association is not really the owner of the id!
-
- if (id!=null) scheduleBatchLoad(id, session);
-
+ .nullSafeGet( rs, names, session, null );
+ scheduleBatchLoadIfNeeded( id, session );
return id;
}
/**
* Register the entity as batch loadable, if enabled
*/
- private void scheduleBatchLoad(Serializable id, SessionImplementor session)
- throws MappingException {
-
- if (uniqueKeyPropertyName==null) { //cannot batch fetch by unique key
-
- EntityPersister persister = session.getFactory()
- .getEntityPersister( getAssociatedEntityName() );
-
+ private void scheduleBatchLoadIfNeeded(
+ Serializable id,
+ SessionImplementor session) throws MappingException {
+ //cannot batch fetch by unique key (property-ref associations)
+ if ( uniqueKeyPropertyName == null && id != null ) {
+ EntityPersister persister = session.getFactory().getEntityPersister( getAssociatedEntityName() );
EntityKey entityKey = new EntityKey( id, persister, session.getEntityMode() );
- session.getPersistenceContext()
- .getBatchFetchQueue()
- .addBatchLoadableEntityKey( entityKey );
+ if ( !session.getPersistenceContext().containsEntity( entityKey ) ) {
+ session.getPersistenceContext()
+ .getBatchFetchQueue()
+ .addBatchLoadableEntityKey( entityKey );
+ }
}
}
@@ -122,24 +128,33 @@
return false;
}
- public boolean isModified(Object old, Object current, boolean[] checkable, SessionImplementor session)
- throws HibernateException {
-
- if (current==null) return old!=null;
- if (old==null) return current!=null;
- //the ids are fully resolved, so compare them with isDirty(), not isModified()
+ public boolean isModified(
+ Object old,
+ Object current,
+ boolean[] checkable,
+ SessionImplementor session) throws HibernateException {
+ if ( current == null ) {
+ return old!=null;
+ }
+ if ( old == null ) {
+ // we already know current is not null...
+ return true;
+ }
+ // the ids are fully resolved, so compare them with isDirty(), not isModified()
return getIdentifierOrUniqueKeyType( session.getFactory() )
- .isDirty( old, getIdentifier(current, session), session );
+ .isDirty( old, getIdentifier( current, session ), session );
}
- public Serializable disassemble(Object value, SessionImplementor session, Object owner)
- throws HibernateException {
+ public Serializable disassemble(
+ Object value,
+ SessionImplementor session,
+ Object owner) throws HibernateException {
- if ( isNotEmbedded(session) ) {
- return getIdentifierType(session).disassemble(value, session, owner);
+ if ( isNotEmbedded( session ) ) {
+ return getIdentifierType( session ).disassemble( value, session, owner );
}
- if (value==null) {
+ if ( value == null ) {
return null;
}
else {
@@ -148,78 +163,84 @@
Object id = ForeignKeys.getEntityIdentifierIfNotUnsaved(
getAssociatedEntityName(),
value,
- session
- );
- if (id==null) {
+ session
+ );
+ if ( id == null ) {
throw new AssertionFailure(
"cannot cache a reference to an object with a null id: " +
- getAssociatedEntityName()
- );
+ getAssociatedEntityName()
+ );
}
- return getIdentifierType(session).disassemble(id, session, owner);
+ return getIdentifierType( session ).disassemble( id, session, owner );
}
}
- public Object assemble(Serializable oid, SessionImplementor session, Object owner)
- throws HibernateException {
+ public Object assemble(
+ Serializable oid,
+ SessionImplementor session,
+ Object owner) throws HibernateException {
//TODO: currently broken for unique-key references (does not detect
// change to unique key property of the associated object)
Serializable id = assembleId( oid, session );
- if ( isNotEmbedded(session) ) return id;
+ if ( isNotEmbedded( session ) ) {
+ return id;
+ }
- if (id==null) {
+ if ( id == null ) {
return null;
}
else {
- return resolveIdentifier(id, session);
+ return resolveIdentifier( id, session );
}
}
private Serializable assembleId(Serializable oid, SessionImplementor session) {
- return (Serializable) getIdentifierType(session)
- .assemble(oid, session, null); //the owner of the association is not the owner of the id
+ //the owner of the association is not the owner of the id
+ return ( Serializable ) getIdentifierType( session ).assemble( oid, session, null );
}
public void beforeAssemble(Serializable oid, SessionImplementor session) {
- if ( uniqueKeyPropertyName==null && oid!=null ) {
- EntityPersister persister = session.getFactory().getEntityPersister( getAssociatedEntityName() );
- EntityKey key = new EntityKey( assembleId(oid, session), persister, session.getEntityMode() );
- session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey(key);
- }
+ scheduleBatchLoadIfNeeded( assembleId( oid, session ), session );
}
public boolean[] toColumnNullness(Object value, Mapping mapping) {
- boolean[] result = new boolean[ getColumnSpan(mapping) ];
- if (value!=null) Arrays.fill(result, true);
+ boolean[] result = new boolean[ getColumnSpan( mapping ) ];
+ if ( value != null ) {
+ Arrays.fill( result, true );
+ }
return result;
}
- public boolean isDirty(Object old, Object current, SessionImplementor session)
- throws HibernateException {
-
- if ( isSame( old, current, session.getEntityMode() ) ) return false;
-
- Object oldid = getIdentifier(old, session);
- Object newid = getIdentifier(current, session);
- return getIdentifierType(session).isDirty( oldid, newid, session );
-
+ public boolean isDirty(
+ Object old,
+ Object current,
+ SessionImplementor session) throws HibernateException {
+ if ( isSame( old, current, session.getEntityMode() ) ) {
+ return false;
+ }
+ Object oldid = getIdentifier( old, session );
+ Object newid = getIdentifier( current, session );
+ return getIdentifierType( session ).isDirty( oldid, newid, session );
}
- public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session)
- throws HibernateException {
-
+ public boolean isDirty(
+ Object old,
+ Object current,
+ boolean[] checkable,
+ SessionImplementor session) throws HibernateException {
if ( isAlwaysDirtyChecked() ) {
- return isDirty(old, current, session);
+ return isDirty( old, current, session );
}
else {
- if ( isSame( old, current, session.getEntityMode() ) ) return false;
-
- Object oldid = getIdentifier(old, session);
- Object newid = getIdentifier(current, session);
- return getIdentifierType(session).isDirty( oldid, newid, checkable, session );
+ if ( isSame( old, current, session.getEntityMode() ) ) {
+ return false;
+ }
+ Object oldid = getIdentifier( old, session );
+ Object newid = getIdentifier( current, session );
+ return getIdentifierType( session ).isDirty( oldid, newid, checkable, session );
}
}
|
|
From: <hib...@li...> - 2006-06-15 07:51:33
|
Author: ste...@jb...
Date: 2006-06-15 03:50:12 -0400 (Thu, 15 Jun 2006)
New Revision: 10019
Modified:
trunk/Hibernate3/src/org/hibernate/FlushMode.java
trunk/Hibernate3/src/org/hibernate/cfg/HbmBinder.java
trunk/Hibernate3/src/org/hibernate/impl/SessionImpl.java
trunk/Hibernate3/src/org/hibernate/persister/collection/NamedQueryCollectionInitializer.java
trunk/Hibernate3/src/org/hibernate/persister/entity/NamedQueryLoader.java
Log:
HHH-1839 : added FlushMode.MANUAL; deprecated FlushMode.NEVER
Modified: trunk/Hibernate3/src/org/hibernate/FlushMode.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/FlushMode.java 2006-06-15 05:21:06 UTC (rev 10018)
+++ trunk/Hibernate3/src/org/hibernate/FlushMode.java 2006-06-15 07:50:12 UTC (rev 10019)
@@ -14,34 +14,48 @@
* @author Gavin King
*/
public final class FlushMode implements Serializable {
+ private static final Map INSTANCES = new HashMap();
+
private final int level;
private final String name;
- private static final Map INSTANCES = new HashMap();
private FlushMode(int level, String name) {
- this.level=level;
- this.name=name;
+ this.level = level;
+ this.name = name;
}
public String toString() {
return name;
}
+
/**
* The <tt>Session</tt> is never flushed unless <tt>flush()</tt>
* is explicitly called by the application. This mode is very
* efficient for read only transactions.
+ *
+ * @deprecated use {@link #MANUAL} instead.
*/
- public static final FlushMode NEVER = new FlushMode(0, "NEVER");
+ public static final FlushMode NEVER = new FlushMode( 0, "NEVER" );
+
/**
+ * The <tt>Session</tt> is onyl eve flushed when <tt>flush()</tt>
+ * is explicitly called by the application. This mode is very
+ * efficient for read only transactions.
+ */
+ public static final FlushMode MANUAL = new FlushMode( 0, "MANUAL" );
+
+ /**
* The <tt>Session</tt> is flushed when <tt>Transaction.commit()</tt>
* is called.
*/
public static final FlushMode COMMIT = new FlushMode(5, "COMMIT");
+
/**
* The <tt>Session</tt> is sometimes flushed before query execution
* in order to ensure that queries never return stale state. This
* is the default flush mode.
*/
public static final FlushMode AUTO = new FlushMode(10, "AUTO");
+
/**
* The <tt>Session</tt> is flushed before every query. This is
* almost always unnecessary and inefficient.
@@ -54,11 +68,16 @@
static {
INSTANCES.put( NEVER.name, NEVER );
+ INSTANCES.put( MANUAL.name, MANUAL );
INSTANCES.put( AUTO.name, AUTO );
INSTANCES.put( ALWAYS.name, ALWAYS );
INSTANCES.put( COMMIT.name, COMMIT );
}
+ public static boolean isManualFlushMode(FlushMode mode) {
+ return MANUAL.level == mode.level;
+ }
+
private Object readResolve() {
return INSTANCES.get( name );
}
Modified: trunk/Hibernate3/src/org/hibernate/cfg/HbmBinder.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/cfg/HbmBinder.java 2006-06-15 05:21:06 UTC (rev 10018)
+++ trunk/Hibernate3/src/org/hibernate/cfg/HbmBinder.java 2006-06-15 07:50:12 UTC (rev 10019)
@@ -2530,6 +2530,9 @@
else if ( "never".equals( flushMode ) ) {
return FlushMode.NEVER;
}
+ else if ( "manual".equals( flushMode ) ) {
+ return FlushMode.MANUAL;
+ }
else if ( "always".equals( flushMode ) ) {
return FlushMode.ALWAYS;
}
Modified: trunk/Hibernate3/src/org/hibernate/impl/SessionImpl.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/impl/SessionImpl.java 2006-06-15 05:21:06 UTC (rev 10018)
+++ trunk/Hibernate3/src/org/hibernate/impl/SessionImpl.java 2006-06-15 07:50:12 UTC (rev 10019)
@@ -322,7 +322,7 @@
}
public boolean isFlushModeNever() {
- return getFlushMode() == FlushMode.NEVER;
+ return FlushMode.isManualFlushMode( getFlushMode() );
}
public boolean isFlushBeforeCompletionEnabled() {
Modified: trunk/Hibernate3/src/org/hibernate/persister/collection/NamedQueryCollectionInitializer.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/persister/collection/NamedQueryCollectionInitializer.java 2006-06-15 05:21:06 UTC (rev 10018)
+++ trunk/Hibernate3/src/org/hibernate/persister/collection/NamedQueryCollectionInitializer.java 2006-06-15 07:50:12 UTC (rev 10019)
@@ -51,8 +51,8 @@
else {
query.setParameter( 0, key, persister.getKeyType() );
}
- query.setCollectionKey(key)
- .setFlushMode(FlushMode.NEVER)
+ query.setCollectionKey( key )
+ .setFlushMode( FlushMode.MANUAL )
.list();
}
Modified: trunk/Hibernate3/src/org/hibernate/persister/entity/NamedQueryLoader.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/persister/entity/NamedQueryLoader.java 2006-06-15 05:21:06 UTC (rev 10018)
+++ trunk/Hibernate3/src/org/hibernate/persister/entity/NamedQueryLoader.java 2006-06-15 07:50:12 UTC (rev 10019)
@@ -53,7 +53,7 @@
query.setOptionalId(id);
query.setOptionalEntityName( persister.getEntityName() );
query.setOptionalObject(optionalObject);
- query.setFlushMode(FlushMode.NEVER);
+ query.setFlushMode( FlushMode.MANUAL );
query.list();
// now look up the object we are really interested in!
|
|
From: <hib...@li...> - 2006-06-15 05:28:37
|
Author: ste...@jb...
Date: 2006-06-15 01:21:06 -0400 (Thu, 15 Jun 2006)
New Revision: 10018
Added:
trunk/Hibernate3/src/org/hibernate/engine/query/sql/
trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java
trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java
trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java
trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java
trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java
trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java
trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java
trunk/Hibernate3/src/org/hibernate/loader/custom/CollectionFetchReturn.java
trunk/Hibernate3/src/org/hibernate/loader/custom/CollectionReturn.java
trunk/Hibernate3/src/org/hibernate/loader/custom/EntityFetchReturn.java
trunk/Hibernate3/src/org/hibernate/loader/custom/FetchReturn.java
trunk/Hibernate3/src/org/hibernate/loader/custom/NonScalarReturn.java
trunk/Hibernate3/src/org/hibernate/loader/custom/Return.java
trunk/Hibernate3/src/org/hibernate/loader/custom/RootReturn.java
trunk/Hibernate3/src/org/hibernate/loader/custom/ScalarReturn.java
trunk/Hibernate3/src/org/hibernate/loader/custom/sql/
trunk/Hibernate3/src/org/hibernate/loader/custom/sql/SQLCustomQuery.java
trunk/Hibernate3/src/org/hibernate/loader/custom/sql/SQLQueryParser.java
trunk/Hibernate3/src/org/hibernate/loader/custom/sql/SQLQueryReturnProcessor.java
Removed:
trunk/Hibernate3/src/org/hibernate/engine/query/NativeSQLQuerySpecification.java
trunk/Hibernate3/src/org/hibernate/loader/custom/SQLCustomQuery.java
trunk/Hibernate3/src/org/hibernate/loader/custom/SQLQueryCollectionReturn.java
trunk/Hibernate3/src/org/hibernate/loader/custom/SQLQueryJoinReturn.java
trunk/Hibernate3/src/org/hibernate/loader/custom/SQLQueryParser.java
trunk/Hibernate3/src/org/hibernate/loader/custom/SQLQueryReturn.java
trunk/Hibernate3/src/org/hibernate/loader/custom/SQLQueryReturnProcessor.java
trunk/Hibernate3/src/org/hibernate/loader/custom/SQLQueryRootReturn.java
trunk/Hibernate3/src/org/hibernate/loader/custom/SQLQueryScalarReturn.java
Modified:
trunk/Hibernate3/src/org/hibernate/cfg/NamedSQLQuerySecondPass.java
trunk/Hibernate3/src/org/hibernate/cfg/ResultSetMappingBinder.java
trunk/Hibernate3/src/org/hibernate/engine/NamedSQLQueryDefinition.java
trunk/Hibernate3/src/org/hibernate/engine/ResultSetMappingDefinition.java
trunk/Hibernate3/src/org/hibernate/engine/SessionImplementor.java
trunk/Hibernate3/src/org/hibernate/engine/query/NativeSQLQueryPlan.java
trunk/Hibernate3/src/org/hibernate/engine/query/QueryPlanCache.java
trunk/Hibernate3/src/org/hibernate/impl/AbstractSessionImpl.java
trunk/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java
trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java
trunk/Hibernate3/src/org/hibernate/impl/SessionImpl.java
trunk/Hibernate3/src/org/hibernate/impl/StatelessSessionImpl.java
trunk/Hibernate3/src/org/hibernate/loader/Loader.java
trunk/Hibernate3/src/org/hibernate/loader/custom/CustomLoader.java
trunk/Hibernate3/src/org/hibernate/loader/custom/CustomQuery.java
trunk/Hibernate3/test/org/hibernate/test/sql/General.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
trunk/Hibernate3/test/org/hibernate/test/sql/OracleSQLTest.java
Log:
native sql result ordering
Modified: trunk/Hibernate3/src/org/hibernate/cfg/NamedSQLQuerySecondPass.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/cfg/NamedSQLQuerySecondPass.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/cfg/NamedSQLQuerySecondPass.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -69,17 +69,16 @@
HbmBinder.getCacheMode( cacheMode ),
readOnly,
comment,
- HbmBinder.getParameterTypes(queryElem),
+ HbmBinder.getParameterTypes( queryElem ),
callable
- );
+ );
//TODO check there is no actual definition elemnents when a ref is defined
}
else {
- ResultSetMappingDefinition definition = buildResultSetMappingDefinition(queryElem, path, mappings);
+ ResultSetMappingDefinition definition = buildResultSetMappingDefinition( queryElem, path, mappings );
namedQuery = new NamedSQLQueryDefinition(
queryElem.getText(),
- definition.getEntityQueryReturns(),
- definition.getScalarQueryReturns(),
+ definition.getQueryReturns(),
synchronizedTables,
cacheable,
region,
@@ -89,9 +88,9 @@
HbmBinder.getCacheMode( cacheMode ),
readOnly,
comment,
- HbmBinder.getParameterTypes(queryElem),
+ HbmBinder.getParameterTypes( queryElem ),
callable
- );
+ );
}
log.debug( "Named SQL query: " + queryName + " -> " + namedQuery.getQueryString() );
Modified: trunk/Hibernate3/src/org/hibernate/cfg/ResultSetMappingBinder.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/cfg/ResultSetMappingBinder.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/cfg/ResultSetMappingBinder.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -12,11 +12,11 @@
import org.dom4j.Element;
import org.hibernate.LockMode;
import org.hibernate.MappingException;
+import org.hibernate.engine.query.sql.NativeSQLQueryCollectionReturn;
import org.hibernate.engine.ResultSetMappingDefinition;
-import org.hibernate.loader.custom.SQLQueryCollectionReturn;
-import org.hibernate.loader.custom.SQLQueryJoinReturn;
-import org.hibernate.loader.custom.SQLQueryRootReturn;
-import org.hibernate.loader.custom.SQLQueryScalarReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryJoinReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryScalarReturn;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Value;
@@ -32,44 +32,53 @@
* @author Emmanuel Bernard
*/
public abstract class ResultSetMappingBinder {
+ /**
+ * Build a ResultSetMappingDefinition given a containing element for the "return-XXX" elements
+ *
+ * @param resultSetElem The element containing the return definitions.
+ * @param path No clue...
+ * @param mappings The current processing state.
+ * @return The description of the mappings...
+ */
protected static ResultSetMappingDefinition buildResultSetMappingDefinition(Element resultSetElem, String path, Mappings mappings) {
String resultSetName = resultSetElem.attribute( "name" ).getValue();
- if (path != null) resultSetName = path + '.' + resultSetName;
+ if ( path != null ) {
+ resultSetName = path + '.' + resultSetName;
+ }
ResultSetMappingDefinition definition = new ResultSetMappingDefinition( resultSetName );
- Iterator returns = resultSetElem.elementIterator( "return-scalar" );
- while ( returns.hasNext() ) {
- Element returnElem = (Element) returns.next();
- String column = returnElem.attributeValue( "column" );
- String typeFromXML = HbmBinder.getTypeFromXML( returnElem );
- Type type = null;
- if(typeFromXML!=null) {
- type = TypeFactory.heuristicType( typeFromXML );
- if ( type == null ) {
- throw new MappingException( "could not determine type " + type );
- }
- }
- definition.addScalarQueryReturn( new SQLQueryScalarReturn( column, type ) );
- }
- returns = resultSetElem.elementIterator();
+
int cnt = 0;
+ Iterator returns = resultSetElem.elementIterator();
while ( returns.hasNext() ) {
cnt++;
Element returnElem = (Element) returns.next();
String name = returnElem.getName();
- if ( "return".equals( name ) ) {
- definition.addEntityQueryReturn( bindReturn( returnElem, mappings, cnt ) );
+ if ( "return-scalar".equals( name ) ) {
+ String column = returnElem.attributeValue( "column" );
+ String typeFromXML = HbmBinder.getTypeFromXML( returnElem );
+ Type type = null;
+ if(typeFromXML!=null) {
+ type = TypeFactory.heuristicType( typeFromXML );
+ if ( type == null ) {
+ throw new MappingException( "could not determine type " + type );
+ }
+ }
+ definition.addQueryReturn( new NativeSQLQueryScalarReturn( column, type ) );
}
+ else if ( "return".equals( name ) ) {
+ definition.addQueryReturn( bindReturn( returnElem, mappings, cnt ) );
+ }
else if ( "return-join".equals( name ) ) {
- definition.addEntityQueryReturn( bindReturnJoin( returnElem, mappings ) );
+ definition.addQueryReturn( bindReturnJoin( returnElem, mappings ) );
}
else if ( "load-collection".equals( name ) ) {
- definition.addEntityQueryReturn( bindLoadCollection( returnElem, mappings ) );
+ definition.addQueryReturn( bindLoadCollection( returnElem, mappings ) );
}
}
return definition;
}
- private static SQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) {
+ private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) {
String alias = returnElem.attributeValue( "alias" );
if( StringHelper.isEmpty(alias)) {
alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key.
@@ -84,7 +93,7 @@
PersistentClass pc = mappings.getClass( entityName );
java.util.Map propertyResults = bindPropertyResults(alias, returnElem, pc, mappings );
- return new SQLQueryRootReturn(
+ return new NativeSQLQueryRootReturn(
alias,
entityName,
propertyResults,
@@ -92,7 +101,7 @@
);
}
- private static SQLQueryJoinReturn bindReturnJoin(Element returnElem, Mappings mappings) {
+ private static NativeSQLQueryJoinReturn bindReturnJoin(Element returnElem, Mappings mappings) {
String alias = returnElem.attributeValue( "alias" );
String roleAttribute = returnElem.attributeValue( "property" );
LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
@@ -109,7 +118,7 @@
//FIXME: get the PersistentClass
java.util.Map propertyResults = bindPropertyResults(alias, returnElem, null, mappings );
- return new SQLQueryJoinReturn(
+ return new NativeSQLQueryJoinReturn(
alias,
roleOwnerAlias,
roleProperty,
@@ -118,7 +127,7 @@
);
}
- private static SQLQueryCollectionReturn bindLoadCollection(Element returnElem, Mappings mappings) {
+ private static NativeSQLQueryCollectionReturn bindLoadCollection(Element returnElem, Mappings mappings) {
String alias = returnElem.attributeValue( "alias" );
String collectionAttribute = returnElem.attributeValue( "role" );
LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
@@ -135,7 +144,7 @@
//FIXME: get the PersistentClass
java.util.Map propertyResults = bindPropertyResults(alias, returnElem, null, mappings );
- return new SQLQueryCollectionReturn(
+ return new NativeSQLQueryCollectionReturn(
alias,
ownerClassName,
ownerPropertyName,
@@ -331,7 +340,7 @@
return name;
}
- private static final LockMode getLockMode(String lockMode) {
+ private static LockMode getLockMode(String lockMode) {
if ( lockMode == null || "read".equals( lockMode ) ) {
return LockMode.READ;
}
Modified: trunk/Hibernate3/src/org/hibernate/engine/NamedSQLQueryDefinition.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/NamedSQLQueryDefinition.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/NamedSQLQueryDefinition.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -6,9 +6,7 @@
import org.hibernate.FlushMode;
import org.hibernate.CacheMode;
-import org.hibernate.engine.query.NativeSQLQuerySpecification;
-import org.hibernate.loader.custom.SQLQueryReturn;
-import org.hibernate.loader.custom.SQLQueryScalarReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
/**
* Definition of a named native SQL query, defined
@@ -18,8 +16,7 @@
*/
public class NamedSQLQueryDefinition extends NamedQueryDefinition {
- private SQLQueryReturn[] queryReturns;
- private SQLQueryScalarReturn[] scalarReturns;
+ private NativeSQLQueryReturn[] queryReturns;
private final List querySpaces;
private final boolean callable;
private String resultSetRef;
@@ -31,7 +28,6 @@
*
* @param query The sql query string
* @param queryReturns The in-lined query return definitions
- * @param scalarReturns The in-lined scalar query return definitions
* @param querySpaces Any specified query spaces (used for auto-flushing)
* @param cacheable Whether the query results are cacheable
* @param cacheRegion If cacheable, the region into which to store the results
@@ -46,8 +42,7 @@
*/
public NamedSQLQueryDefinition(
String query,
- SQLQueryReturn[] queryReturns,
- SQLQueryScalarReturn[] scalarReturns,
+ NativeSQLQueryReturn[] queryReturns,
List querySpaces,
boolean cacheable,
String cacheRegion,
@@ -72,7 +67,6 @@
parameterTypes
);
this.queryReturns = queryReturns;
- this.scalarReturns = scalarReturns;
this.querySpaces = querySpaces;
this.callable = callable;
}
@@ -169,14 +163,10 @@
);
}
- public SQLQueryReturn[] getQueryReturns() {
+ public NativeSQLQueryReturn[] getQueryReturns() {
return queryReturns;
}
- public SQLQueryScalarReturn[] getScalarQueryReturns() {
- return scalarReturns;
- }
-
public List getQuerySpaces() {
return querySpaces;
}
Modified: trunk/Hibernate3/src/org/hibernate/engine/ResultSetMappingDefinition.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/ResultSetMappingDefinition.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/ResultSetMappingDefinition.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -5,8 +5,7 @@
import java.util.List;
import java.io.Serializable;
-import org.hibernate.loader.custom.SQLQueryReturn;
-import org.hibernate.loader.custom.SQLQueryScalarReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
/**
* Keep a description of the resultset mapping
@@ -14,33 +13,34 @@
* @author Emmanuel Bernard
*/
public class ResultSetMappingDefinition implements Serializable {
- /** List<SQLQueryReturn> */
- private List entityQueryReturns = new ArrayList();
- /** List<SQLQueryScalarReturn> */
- private List scalarQueryReturns = new ArrayList();
- private String name;
- public String getName() {
- return name;
- }
+ private final String name;
+ private final List /*NativeSQLQueryReturn*/ queryReturns = new ArrayList();
public ResultSetMappingDefinition(String name) {
this.name = name;
}
- public void addEntityQueryReturn(SQLQueryReturn entityQueryReturn) {
- entityQueryReturns.add(entityQueryReturn);
+ public String getName() {
+ return name;
}
- public void addScalarQueryReturn(SQLQueryScalarReturn scalarQueryReturn) {
- scalarQueryReturns.add(scalarQueryReturn);
+ public void addQueryReturn(NativeSQLQueryReturn queryReturn) {
+ queryReturns.add( queryReturn );
}
- public SQLQueryReturn[] getEntityQueryReturns() {
- return (SQLQueryReturn[]) entityQueryReturns.toArray( new SQLQueryReturn[0] );
+// We could also keep these if needed for binary compatibility with annotations, provided
+// it only uses the addXXX() methods...
+// public void addEntityQueryReturn(NativeSQLQueryNonScalarReturn entityQueryReturn) {
+// entityQueryReturns.add(entityQueryReturn);
+// }
+//
+// public void addScalarQueryReturn(NativeSQLQueryScalarReturn scalarQueryReturn) {
+// scalarQueryReturns.add(scalarQueryReturn);
+// }
+
+ public NativeSQLQueryReturn[] getQueryReturns() {
+ return ( NativeSQLQueryReturn[] ) queryReturns.toArray( new NativeSQLQueryReturn[0] );
}
- public SQLQueryScalarReturn[] getScalarQueryReturns() {
- return (SQLQueryScalarReturn[]) scalarQueryReturns.toArray( new SQLQueryScalarReturn[0] );
- }
}
Modified: trunk/Hibernate3/src/org/hibernate/engine/SessionImplementor.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/SessionImplementor.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/SessionImplementor.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -16,7 +16,7 @@
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Transaction;
-import org.hibernate.engine.query.NativeSQLQuerySpecification;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.collection.PersistentCollection;
import org.hibernate.event.EventListeners;
import org.hibernate.impl.CriteriaImpl;
Modified: trunk/Hibernate3/src/org/hibernate/engine/query/NativeSQLQueryPlan.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/query/NativeSQLQueryPlan.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/query/NativeSQLQueryPlan.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -1,7 +1,6 @@
package org.hibernate.engine.query;
import java.io.Serializable;
-import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Iterator;
@@ -12,6 +11,7 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.QueryException;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.action.BulkOperationCleanupAction;
import org.hibernate.engine.QueryParameters;
import org.hibernate.engine.SessionFactoryImplementor;
@@ -19,15 +19,14 @@
import org.hibernate.engine.TypedValue;
import org.hibernate.event.EventSource;
import org.hibernate.exception.JDBCExceptionHelper;
-import org.hibernate.loader.custom.SQLCustomQuery;
-import org.hibernate.pretty.Formatter;
+import org.hibernate.loader.custom.sql.SQLCustomQuery;
import org.hibernate.type.Type;
import org.hibernate.util.ArrayHelper;
/**
* Defines a query execution plan for a native-SQL query.
*
- * @author <a href="mailto:st...@hi...">Steve Ebersole </a>
+ * @author Steve Ebersole
*/
public class NativeSQLQueryPlan implements Serializable {
private final String sourceQuery;
@@ -36,13 +35,15 @@
private static final Log log = LogFactory.getLog(NativeSQLQueryPlan.class);
- public NativeSQLQueryPlan(NativeSQLQuerySpecification specification,
+ public NativeSQLQueryPlan(
+ NativeSQLQuerySpecification specification,
SessionFactoryImplementor factory) {
this.sourceQuery = specification.getQueryString();
- customQuery = new SQLCustomQuery( specification.getSqlQueryReturns(),
- specification.getSqlQueryScalarReturns(), specification
- .getQueryString(), specification.getQuerySpaces(),
+ customQuery = new SQLCustomQuery(
+ specification.getQueryString(),
+ specification.getQueryReturns(),
+ specification.getQuerySpaces(),
factory );
}
@@ -147,7 +148,7 @@
}
int result = 0;
- PreparedStatement ps = null;
+ PreparedStatement ps;
try {
queryParameters.processFilters( this.customQuery.getSQL(),
session );
Deleted: trunk/Hibernate3/src/org/hibernate/engine/query/NativeSQLQuerySpecification.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/query/NativeSQLQuerySpecification.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/query/NativeSQLQuerySpecification.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -1,93 +0,0 @@
-package org.hibernate.engine.query;
-
-import org.hibernate.loader.custom.SQLQueryReturn;
-import org.hibernate.loader.custom.SQLQueryScalarReturn;
-import org.hibernate.util.ArrayHelper;
-
-import java.util.Set;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Arrays;
-import java.util.Collections;
-
-/**
- * Defines the specification or blue-print for a native-sql query.
- * Essentially a simple struct containing the information needed to "translate"
- * a native-sql query and cache that translated representation. Also used as
- * the key by which the native-sql query plans are cached.
- *
- * @author Steve Ebersole
- */
-public class NativeSQLQuerySpecification {
- private final String queryString;
- private final SQLQueryReturn[] sqlQueryReturns;
- private final SQLQueryScalarReturn[] sqlQueryScalarReturns;
- private final Set querySpaces;
- private final int hashCode;
-
- public NativeSQLQuerySpecification(
- String queryString,
- SQLQueryReturn[] sqlQueryReturns,
- SQLQueryScalarReturn[] sqlQueryScalarReturns,
- Collection querySpaces) {
- this.queryString = queryString;
- this.sqlQueryReturns = sqlQueryReturns;
- this.sqlQueryScalarReturns = sqlQueryScalarReturns;
- if ( querySpaces == null ) {
- this.querySpaces = Collections.EMPTY_SET;
- }
- else {
- Set tmp = new HashSet();
- tmp.addAll( querySpaces );
- this.querySpaces = Collections.unmodifiableSet( tmp );
- }
-
- // pre-determine and cache the hashcode
- int hashCode = queryString.hashCode();
- hashCode = 29 * hashCode + this.querySpaces.hashCode();
- if ( this.sqlQueryReturns != null ) {
- hashCode = 29 * hashCode + ArrayHelper.toList( this.sqlQueryReturns ).hashCode();
- }
- if ( this.sqlQueryScalarReturns != null ) {
- hashCode = 29 * hashCode + ArrayHelper.toList( this.sqlQueryScalarReturns ).hashCode();
- }
- this.hashCode = hashCode;
- }
-
- public String getQueryString() {
- return queryString;
- }
-
- public SQLQueryReturn[] getSqlQueryReturns() {
- return sqlQueryReturns;
- }
-
- public SQLQueryScalarReturn[] getSqlQueryScalarReturns() {
- return sqlQueryScalarReturns;
- }
-
- public Set getQuerySpaces() {
- return querySpaces;
- }
-
- public boolean equals(Object o) {
- if ( this == o ) {
- return true;
- }
- if ( o == null || getClass() != o.getClass() ) {
- return false;
- }
-
- final NativeSQLQuerySpecification that = ( NativeSQLQuerySpecification ) o;
-
- return querySpaces.equals( that.querySpaces ) &&
- queryString.equals( that.queryString ) &&
- Arrays.equals( sqlQueryReturns, that.sqlQueryReturns ) &&
- Arrays.equals( sqlQueryScalarReturns, that.sqlQueryScalarReturns );
- }
-
-
- public int hashCode() {
- return hashCode;
- }
-}
Modified: trunk/Hibernate3/src/org/hibernate/engine/query/QueryPlanCache.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/query/QueryPlanCache.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/query/QueryPlanCache.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -4,6 +4,7 @@
import org.hibernate.util.SimpleMRUCache;
import org.hibernate.util.SoftLimitMRUCache;
import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.QueryException;
import org.hibernate.MappingException;
import org.apache.commons.logging.Log;
Added: trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -0,0 +1,60 @@
+// $Id: NativeSQLQueryCollectionReturn.java 7232 2005-06-19 17:16:40 -0500 (Sun, 19 Jun 2005) maxcsaucdk $
+package org.hibernate.engine.query.sql;
+
+import java.util.Map;
+
+import org.hibernate.LockMode;
+
+/**
+ * Represents a return defined as part of a native sql query which
+ * names a collection role in the form {classname}.{collectionrole}; it
+ * is used in defining a custom sql query for loading an entity's
+ * collection in non-fetching scenarios (i.e., loading the collection
+ * itself as the "root" of the result).
+ *
+ * @author Steve Ebersole
+ */
+public class NativeSQLQueryCollectionReturn extends NativeSQLQueryNonScalarReturn {
+ private String ownerEntityName;
+ private String ownerProperty;
+
+ /**
+ * Construct a native-sql return representing a collection initializer
+ *
+ * @param alias The result alias
+ * @param ownerEntityName The entity-name of the entity owning the collection
+ * to be initialized.
+ * @param ownerProperty The property name (on the owner) which represents
+ * the collection to be initialized.
+ * @param propertyResults Any user-supplied column->property mappings
+ * @param lockMode The lock mode to apply to the collection.
+ */
+ public NativeSQLQueryCollectionReturn(
+ String alias,
+ String ownerEntityName,
+ String ownerProperty,
+ Map propertyResults,
+ LockMode lockMode) {
+ super( alias, propertyResults, lockMode );
+ this.ownerEntityName = ownerEntityName;
+ this.ownerProperty = ownerProperty;
+ }
+
+ /**
+ * Returns the class owning the collection.
+ *
+ * @return The class owning the collection.
+ */
+ public String getOwnerEntityName() {
+ return ownerEntityName;
+ }
+
+ /**
+ * Returns the name of the property representing the collection from the {@link #getOwnerEntityName}.
+ *
+ * @return The name of the property representing the collection on the owner class.
+ */
+ public String getOwnerProperty() {
+ return ownerProperty;
+ }
+}
Added: trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -0,0 +1,56 @@
+// $Id: NativeSQLQueryJoinReturn.java 7232 2005-06-19 17:16:40 -0500 (Sun, 19 Jun 2005) maxcsaucdk $
+package org.hibernate.engine.query.sql;
+
+import java.util.Map;
+
+import org.hibernate.LockMode;
+
+/**
+ * Represents a return defined as part of a native sql query which
+ * names a fetched role.
+ *
+ * @author Steve Ebersole
+ */
+public class NativeSQLQueryJoinReturn extends NativeSQLQueryNonScalarReturn {
+ private String ownerAlias;
+ private String ownerProperty;
+
+ /**
+ * Construct a return descriptor representing some form of fetch.
+ *
+ * @param alias The result alias
+ * @param ownerAlias The owner's result alias
+ * @param ownerProperty The owner's property representing the thing to be fetched
+ * @param propertyResults Any user-supplied column->property mappings
+ * @param lockMode The lock mode to apply
+ */
+ public NativeSQLQueryJoinReturn(
+ String alias,
+ String ownerAlias,
+ String ownerProperty,
+ Map propertyResults,
+ LockMode lockMode) {
+ super( alias, propertyResults, lockMode );
+ this.ownerAlias = ownerAlias;
+ this.ownerProperty = ownerProperty;
+ }
+
+ /**
+ * Retrieve the alias of the owner of this fetched association.
+ *
+ * @return The owner's alias.
+ */
+ public String getOwnerAlias() {
+ return ownerAlias;
+ }
+
+ /**
+ * Retrieve the property name (relative to the owner) which maps to
+ * the association to be fetched.
+ *
+ * @return The property name.
+ */
+ public String getOwnerProperty() {
+ return ownerProperty;
+ }
+}
Added: trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -0,0 +1,67 @@
+// $Id: NativeSQLQueryNonScalarReturn.java 7232 2005-06-19 17:16:40 -0500 (Sun, 19 Jun 2005) maxcsaucdk $
+package org.hibernate.engine.query.sql;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+
+/**
+ * Represents the base information for a non-scalar return defined as part of
+ * a native sql query.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class NativeSQLQueryNonScalarReturn implements NativeSQLQueryReturn, Serializable {
+ private final String alias;
+ private final LockMode lockMode;
+ private final Map propertyResults = new HashMap();
+
+ /**
+ * Constructs some form of non-scalar return descriptor
+ *
+ * @param alias The result alias
+ * @param propertyResults Any user-supplied column->property mappings
+ * @param lockMode The lock mode to apply to the return.
+ */
+ protected NativeSQLQueryNonScalarReturn(String alias, Map propertyResults, LockMode lockMode) {
+ this.alias = alias;
+ if ( alias == null ) {
+ throw new HibernateException("alias must be specified");
+ }
+ this.lockMode = lockMode;
+ if ( propertyResults != null ) {
+ this.propertyResults.putAll( propertyResults );
+ }
+ }
+
+ /**
+ * Retrieve the defined result alias
+ *
+ * @return The result alias.
+ */
+ public String getAlias() {
+ return alias;
+ }
+
+ /**
+ * Retrieve the lock-mode to apply to this return
+ *
+ * @return The lock mode
+ */
+ public LockMode getLockMode() {
+ return lockMode;
+ }
+
+ /**
+ * Retrieve the user-supplied column->property mappings.
+ *
+ * @return The property mappings.
+ */
+ public Map getPropertyResultsMap() {
+ return Collections.unmodifiableMap( propertyResults );
+ }
+}
Added: trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -0,0 +1,9 @@
+package org.hibernate.engine.query.sql;
+
+/**
+ * Describes a return in a native SQL query.
+ *
+ * @author Steve Ebersole
+ */
+public interface NativeSQLQueryReturn {
+}
Added: trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -0,0 +1,52 @@
+// $Id: NativeSQLQueryRootReturn.java 7232 2005-06-19 17:16:40 -0500 (Sun, 19 Jun 2005) maxcsaucdk $
+package org.hibernate.engine.query.sql;
+
+import java.util.Map;
+
+import org.hibernate.LockMode;
+
+/**
+ * Represents a return defined as part of a native sql query which
+ * names a "root" entity. A root entity means it is explicitly a
+ * "column" in the result, as opposed to a fetched relationship or role.
+ *
+ * @author Steve Ebersole
+ */
+public class NativeSQLQueryRootReturn extends NativeSQLQueryNonScalarReturn {
+ private String returnEntityName;
+
+ /**
+ * Construct a return representing an entity returned at the root
+ * of the result.
+ *
+ * @param alias The result alias
+ * @param entityName The entity name.
+ * @param lockMode The lock mode to apply
+ */
+ public NativeSQLQueryRootReturn(String alias, String entityName, LockMode lockMode) {
+ this(alias, entityName, null, lockMode);
+ }
+
+ /**
+ *
+ * @param alias The result alias
+ * @param entityName The entity name.
+ * @param propertyResults Any user-supplied column->property mappings
+ * @param lockMode The lock mode to apply
+ */
+ public NativeSQLQueryRootReturn(String alias, String entityName, Map propertyResults, LockMode lockMode) {
+ super( alias, propertyResults, lockMode );
+ this.returnEntityName = entityName;
+
+ }
+
+ /**
+ * The name of the entity to be returned.
+ *
+ * @return The entity name
+ */
+ public String getReturnEntityName() {
+ return returnEntityName;
+ }
+
+}
Added: trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -0,0 +1,27 @@
+package org.hibernate.engine.query.sql;
+
+import org.hibernate.type.Type;
+
+/**
+ * Describes a scalar return in a native SQL query.
+ *
+ * @author gloegl
+ */
+public class NativeSQLQueryScalarReturn implements NativeSQLQueryReturn {
+ private Type type;
+ private String columnAlias;
+
+ public NativeSQLQueryScalarReturn(String alias, Type type) {
+ this.type = type;
+ this.columnAlias = alias;
+ }
+
+ public String getColumnAlias() {
+ return columnAlias;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+}
Added: trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -0,0 +1,80 @@
+package org.hibernate.engine.query.sql;
+
+import org.hibernate.util.ArrayHelper;
+
+import java.util.Set;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Arrays;
+import java.util.Collections;
+
+/**
+ * Defines the specification or blue-print for a native-sql query.
+ * Essentially a simple struct containing the information needed to "translate"
+ * a native-sql query and cache that translated representation. Also used as
+ * the key by which the native-sql query plans are cached.
+ *
+ * @author Steve Ebersole
+ */
+public class NativeSQLQuerySpecification {
+ private final String queryString;
+ private final NativeSQLQueryReturn[] queryReturns;
+ private final Set querySpaces;
+ private final int hashCode;
+
+ public NativeSQLQuerySpecification(
+ String queryString,
+ NativeSQLQueryReturn[] queryReturns,
+ Collection querySpaces) {
+ this.queryString = queryString;
+ this.queryReturns = queryReturns;
+ if ( querySpaces == null ) {
+ this.querySpaces = Collections.EMPTY_SET;
+ }
+ else {
+ Set tmp = new HashSet();
+ tmp.addAll( querySpaces );
+ this.querySpaces = Collections.unmodifiableSet( tmp );
+ }
+
+ // pre-determine and cache the hashcode
+ int hashCode = queryString.hashCode();
+ hashCode = 29 * hashCode + this.querySpaces.hashCode();
+ if ( this.queryReturns != null ) {
+ hashCode = 29 * hashCode + ArrayHelper.toList( this.queryReturns ).hashCode();
+ }
+ this.hashCode = hashCode;
+ }
+
+ public String getQueryString() {
+ return queryString;
+ }
+
+ public NativeSQLQueryReturn[] getQueryReturns() {
+ return queryReturns;
+ }
+
+ public Set getQuerySpaces() {
+ return querySpaces;
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ final NativeSQLQuerySpecification that = ( NativeSQLQuerySpecification ) o;
+
+ return querySpaces.equals( that.querySpaces ) &&
+ queryString.equals( that.queryString ) &&
+ Arrays.equals( queryReturns, that.queryReturns );
+ }
+
+
+ public int hashCode() {
+ return hashCode;
+ }
+}
Modified: trunk/Hibernate3/src/org/hibernate/impl/AbstractSessionImpl.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/impl/AbstractSessionImpl.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/impl/AbstractSessionImpl.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -7,6 +7,7 @@
import org.hibernate.HibernateException;
import org.hibernate.ScrollableResults;
import org.hibernate.SessionException;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.engine.NamedQueryDefinition;
import org.hibernate.engine.NamedSQLQueryDefinition;
import org.hibernate.engine.SessionImplementor;
@@ -14,7 +15,6 @@
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.query.HQLQueryPlan;
import org.hibernate.engine.query.NativeSQLQueryPlan;
-import org.hibernate.engine.query.NativeSQLQuerySpecification;
import java.util.List;
Modified: trunk/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/impl/SQLQueryImpl.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -17,16 +17,16 @@
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.MappingException;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.NamedSQLQueryDefinition;
import org.hibernate.engine.QueryParameters;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.query.ParameterMetadata;
-import org.hibernate.engine.query.NativeSQLQuerySpecification;
-import org.hibernate.loader.custom.SQLQueryJoinReturn;
-import org.hibernate.loader.custom.SQLQueryReturn;
-import org.hibernate.loader.custom.SQLQueryRootReturn;
-import org.hibernate.loader.custom.SQLQueryScalarReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryJoinReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryScalarReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
import org.hibernate.type.Type;
import org.hibernate.util.CollectionHelper;
import org.hibernate.util.StringHelper;
@@ -47,7 +47,6 @@
public class SQLQueryImpl extends AbstractQueryImpl implements SQLQuery {
private final List queryReturns;
- private final List scalarQueryReturns;
private final Collection querySpaces;
private final boolean callable;
private boolean autodiscovertypes;
@@ -69,11 +68,9 @@
queryDef.getResultSetRef()
);
}
- this.scalarQueryReturns = Arrays.asList( definition.getScalarQueryReturns() );
- this.queryReturns = Arrays.asList( definition.getEntityQueryReturns() );
+ this.queryReturns = Arrays.asList( definition.getQueryReturns() );
}
else {
- this.scalarQueryReturns = Arrays.asList( queryDef.getScalarQueryReturns() );
this.queryReturns = Arrays.asList( queryDef.getQueryReturns() );
}
@@ -84,7 +81,6 @@
SQLQueryImpl(
final String sql,
final List queryReturns,
- final List scalarQueryReturns,
final Collection querySpaces,
final FlushMode flushMode,
boolean callable,
@@ -93,7 +89,6 @@
// TODO : absolutely no usages of this constructor form; can it go away?
super( sql, flushMode, session, parameterMetadata );
this.queryReturns = queryReturns;
- this.scalarQueryReturns = scalarQueryReturns;
this.querySpaces = querySpaces;
this.callable = callable;
}
@@ -109,14 +104,13 @@
ParameterMetadata parameterMetadata) {
// TODO : this constructor form is *only* used from constructor directly below us; can it go away?
super( sql, flushMode, session, parameterMetadata );
- scalarQueryReturns=null;
queryReturns = new ArrayList(returnAliases.length);
for ( int i=0; i<returnAliases.length; i++ ) {
- SQLQueryRootReturn ret = new SQLQueryRootReturn(
+ NativeSQLQueryRootReturn ret = new NativeSQLQueryRootReturn(
returnAliases[i],
returnClasses[i].getName(),
lockModes==null ? LockMode.NONE : lockModes[i]
- );
+ );
queryReturns.add(ret);
}
this.querySpaces = querySpaces;
@@ -135,24 +129,16 @@
SQLQueryImpl(String sql, SessionImplementor session, ParameterMetadata parameterMetadata) {
super( sql, null, session, parameterMetadata );
queryReturns = new ArrayList();
- scalarQueryReturns = new ArrayList();
querySpaces = null;
callable = false;
}
- private static final SQLQueryReturn[] NO_SQL_RETURNS = new SQLQueryReturn[0];
- private static final SQLQueryScalarReturn[] NO_SQL_SCALAR_RETURNS = new SQLQueryScalarReturn[0];
+ private static final NativeSQLQueryReturn[] NO_SQL_RETURNS = new NativeSQLQueryReturn[0];
- private SQLQueryReturn[] getQueryReturns() {
- return (SQLQueryReturn[]) queryReturns.toArray(NO_SQL_RETURNS);
+ private NativeSQLQueryReturn[] getQueryReturns() {
+ return ( NativeSQLQueryReturn[] ) queryReturns.toArray( NO_SQL_RETURNS );
}
- private SQLQueryScalarReturn[] getQueryScalarReturns() {
- return scalarQueryReturns==null ?
- null :
- (SQLQueryScalarReturn[]) scalarQueryReturns.toArray(NO_SQL_SCALAR_RETURNS);
- }
-
public List list() throws HibernateException {
verifyParameters();
before();
@@ -172,7 +158,6 @@
return new NativeSQLQuerySpecification(
expandParameterLists(namedParams),
getQueryReturns(),
- getQueryScalarReturns(),
querySpaces
);
}
@@ -211,22 +196,21 @@
}
protected void verifyParameters() {
- verifyParameters(callable);
- boolean noReturns = ( queryReturns==null || queryReturns.isEmpty() ) &&
- ( scalarQueryReturns==null || scalarQueryReturns.isEmpty() );
- if (noReturns) {
+ verifyParameters( callable );
+ boolean noReturns = queryReturns==null || queryReturns.isEmpty();
+ if ( noReturns ) {
this.autodiscovertypes = noReturns;
- /*throw new QueryException(
- "addEntity() or addScalar() must be called on a sql query before executing the query.",
- getQueryString()
- );*/
}
else {
- if ( scalarQueryReturns != null ) {
- Iterator iter = scalarQueryReturns.iterator();
- while ( iter.hasNext() ) {
- SQLQueryScalarReturn scalar = (SQLQueryScalarReturn) iter.next();
- if ( scalar.getType() == null ) autodiscovertypes = true;
+ Iterator itr = queryReturns.iterator();
+ while ( itr.hasNext() ) {
+ NativeSQLQueryReturn rtn = ( NativeSQLQueryReturn ) itr.next();
+ if ( rtn instanceof NativeSQLQueryScalarReturn ) {
+ NativeSQLQueryScalarReturn scalar = ( NativeSQLQueryScalarReturn ) rtn;
+ if ( scalar.getType() == null ) {
+ autodiscovertypes = true;
+ break;
+ }
}
}
}
@@ -250,13 +234,13 @@
}
public SQLQuery addScalar(String columnAlias, Type type) {
- scalarQueryReturns.add( new SQLQueryScalarReturn(columnAlias, type) );
+ queryReturns.add( new NativeSQLQueryScalarReturn( columnAlias, type ) );
return this;
}
public SQLQuery addScalar(String columnAlias) {
autodiscovertypes = true;
- scalarQueryReturns.add( new SQLQueryScalarReturn(columnAlias, null) );
+ queryReturns.add( new NativeSQLQueryScalarReturn( columnAlias, null ) );
return this;
}
@@ -287,12 +271,12 @@
}
String ownerAlias = path.substring(0, loc);
String role = path.substring(loc+1);
- queryReturns.add( new SQLQueryJoinReturn(alias, ownerAlias, role, CollectionHelper.EMPTY_MAP, lockMode) );
+ queryReturns.add( new NativeSQLQueryJoinReturn(alias, ownerAlias, role, CollectionHelper.EMPTY_MAP, lockMode) );
return this;
}
public SQLQuery addEntity(String alias, String entityName, LockMode lockMode) {
- queryReturns.add( new SQLQueryRootReturn(alias, entityName, lockMode) );
+ queryReturns.add( new NativeSQLQueryRootReturn(alias, entityName, lockMode) );
return this;
}
@@ -301,20 +285,15 @@
}
public SQLQuery setResultSetMapping(String name) {
- ResultSetMappingDefinition mapping = session.getFactory().getResultSetMapping(name);
- if (mapping == null) {
- throw new MappingException("Unknown SqlResultSetMapping named:" + name);
+ ResultSetMappingDefinition mapping = session.getFactory().getResultSetMapping( name );
+ if ( mapping == null ) {
+ throw new MappingException( "Unknown SqlResultSetMapping [" + name + "]" );
}
- SQLQueryReturn[] returns = mapping.getEntityQueryReturns();
+ NativeSQLQueryReturn[] returns = mapping.getQueryReturns();
int length = returns.length;
- for (int index = 0 ; index < length ; index++ ) {
+ for ( int index = 0 ; index < length ; index++ ) {
queryReturns.add( returns[index] );
}
- SQLQueryScalarReturn[] scalarReturns = mapping.getScalarQueryReturns();
- length = scalarReturns.length;
- for (int index = 0 ; index < length ; index++ ) {
- scalarQueryReturns.add( scalarReturns[index] );
- }
return this;
}
Modified: trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -34,6 +34,7 @@
import org.hibernate.QueryException;
import org.hibernate.SessionFactory;
import org.hibernate.StatelessSession;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.cache.Cache;
import org.hibernate.cache.CacheConcurrencyStrategy;
import org.hibernate.cache.CacheFactory;
@@ -57,7 +58,6 @@
import org.hibernate.engine.NamedSQLQueryDefinition;
import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.query.NativeSQLQuerySpecification;
import org.hibernate.engine.query.QueryPlanCache;
import org.hibernate.event.EventListeners;
import org.hibernate.exception.SQLExceptionConverter;
@@ -429,8 +429,7 @@
}
spec = new NativeSQLQuerySpecification(
qd.getQueryString(),
- definition.getEntityQueryReturns(),
- definition.getScalarQueryReturns(),
+ definition.getQueryReturns(),
qd.getQuerySpaces()
);
}
@@ -439,7 +438,6 @@
spec = new NativeSQLQuerySpecification(
qd.getQueryString(),
qd.getQueryReturns(),
- qd.getScalarQueryReturns(),
qd.getQuerySpaces()
);
}
Modified: trunk/Hibernate3/src/org/hibernate/impl/SessionImpl.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/impl/SessionImpl.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/impl/SessionImpl.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -41,6 +41,7 @@
import org.hibernate.Transaction;
import org.hibernate.TransientObjectException;
import org.hibernate.UnresolvableObjectException;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.collection.PersistentCollection;
import org.hibernate.engine.ActionQueue;
import org.hibernate.engine.CollectionEntry;
@@ -54,7 +55,6 @@
import org.hibernate.engine.query.FilterQueryPlan;
import org.hibernate.engine.query.HQLQueryPlan;
import org.hibernate.engine.query.NativeSQLQueryPlan;
-import org.hibernate.engine.query.NativeSQLQuerySpecification;
import org.hibernate.event.AutoFlushEvent;
import org.hibernate.event.AutoFlushEventListener;
import org.hibernate.event.DeleteEvent;
@@ -89,8 +89,6 @@
import org.hibernate.loader.criteria.CriteriaLoader;
import org.hibernate.loader.custom.CustomLoader;
import org.hibernate.loader.custom.CustomQuery;
-import org.hibernate.loader.custom.SQLQueryReturn;
-import org.hibernate.loader.custom.SQLQueryScalarReturn;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.OuterJoinLoadable;
Modified: trunk/Hibernate3/src/org/hibernate/impl/StatelessSessionImpl.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/impl/StatelessSessionImpl.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/impl/StatelessSessionImpl.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -36,7 +36,7 @@
import org.hibernate.engine.Versioning;
import org.hibernate.engine.query.HQLQueryPlan;
import org.hibernate.engine.query.NativeSQLQueryPlan;
-import org.hibernate.engine.query.NativeSQLQuerySpecification;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.event.EventListeners;
import org.hibernate.id.IdentifierGeneratorFactory;
import org.hibernate.jdbc.Batcher;
Modified: trunk/Hibernate3/src/org/hibernate/loader/Loader.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/loader/Loader.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/loader/Loader.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -544,8 +544,7 @@
final EntityKey optionalObjectKey,
final List hydratedObjects,
final EntityKey[] keys,
- boolean returnProxies)
- throws SQLException, HibernateException {
+ boolean returnProxies) throws SQLException, HibernateException {
final Loadable[] persisters = getEntityPersisters();
final int entitySpan = persisters.length;
@@ -575,7 +574,7 @@
lockModeArray,
hydratedObjects,
session
- );
+ );
readCollectionElements( row, resultSet, session );
@@ -646,9 +645,10 @@
}
}
- private List doQuery(final SessionImplementor session,
- final QueryParameters queryParameters,
- final boolean returnProxies) throws SQLException, HibernateException {
+ private List doQuery(
+ final SessionImplementor session,
+ final QueryParameters queryParameters,
+ final boolean returnProxies) throws SQLException, HibernateException {
final RowSelection selection = queryParameters.getRowSelection();
final int maxRows = hasMaxRows( selection ) ?
@@ -695,7 +695,7 @@
hydratedObjects,
keys,
returnProxies
- );
+ );
results.add( result );
if ( createSubselects ) {
@@ -1215,7 +1215,6 @@
}
return rowResults;
-
}
/**
@@ -1674,8 +1673,8 @@
advance( rs, selection );
}
- if(autodiscovertypes) {
- autoDiscoverTypes(rs);
+ if ( autodiscovertypes ) {
+ autoDiscoverTypes( rs );
}
return rs;
}
Added: trunk/Hibernate3/src/org/hibernate/loader/custom/CollectionFetchReturn.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/loader/custom/CollectionFetchReturn.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/loader/custom/CollectionFetchReturn.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -0,0 +1,35 @@
+package org.hibernate.loader.custom;
+
+import org.hibernate.loader.CollectionAliases;
+import org.hibernate.loader.EntityAliases;
+import org.hibernate.LockMode;
+
+/**
+ * Spefically a fetch return that refers to a collection association.
+ *
+ * @author Steve Ebersole
+ */
+public class CollectionFetchReturn extends FetchReturn {
+ private final CollectionAliases collectionAliases;
+ private final EntityAliases elementEntityAliases;
+
+ public CollectionFetchReturn(
+ String alias,
+ NonScalarReturn owner,
+ String ownerProperty,
+ CollectionAliases collectionAliases,
+ EntityAliases elementEntityAliases,
+ LockMode lockMode) {
+ super( owner, ownerProperty, alias, lockMode );
+ this.collectionAliases = collectionAliases;
+ this.elementEntityAliases = elementEntityAliases;
+ }
+
+ public CollectionAliases getCollectionAliases() {
+ return collectionAliases;
+ }
+
+ public EntityAliases getElementEntityAliases() {
+ return elementEntityAliases;
+ }
+}
Added: trunk/Hibernate3/src/org/hibernate/loader/custom/CollectionReturn.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/loader/custom/CollectionReturn.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/loader/custom/CollectionReturn.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -0,0 +1,60 @@
+package org.hibernate.loader.custom;
+
+import org.hibernate.LockMode;
+import org.hibernate.loader.CollectionAliases;
+import org.hibernate.loader.EntityAliases;
+
+/**
+ * Represents a return which names a collection role; it
+ * is used in defining a custom query for loading an entity's
+ * collection in non-fetching scenarios (i.e., loading the collection
+ * itself as the "root" of the result).
+ *
+ * @author Steve Ebersole
+ */
+public class CollectionReturn extends NonScalarReturn {
+ private final String ownerEntityName;
+ private final String ownerProperty;
+ private final CollectionAliases collectionAliases;
+ private final EntityAliases elementEntityAliases;
+
+ public CollectionReturn(
+ String alias,
+ String ownerEntityName,
+ String ownerProperty,
+ CollectionAliases collectionAliases,
+ EntityAliases elementEntityAliases,
+ LockMode lockMode) {
+ super( alias, lockMode );
+ this.ownerEntityName = ownerEntityName;
+ this.ownerProperty = ownerProperty;
+ this.collectionAliases = collectionAliases;
+ this.elementEntityAliases = elementEntityAliases;
+ }
+
+ /**
+ * Returns the class owning the collection.
+ *
+ * @return The class owning the collection.
+ */
+ public String getOwnerEntityName() {
+ return ownerEntityName;
+ }
+
+ /**
+ * Returns the name of the property representing the collection from the {@link #getOwnerEntityName}.
+ *
+ * @return The name of the property representing the collection on the owner class.
+ */
+ public String getOwnerProperty() {
+ return ownerProperty;
+ }
+
+ public CollectionAliases getCollectionAliases() {
+ return collectionAliases;
+ }
+
+ public EntityAliases getElementEntityAliases() {
+ return elementEntityAliases;
+ }
+}
Modified: trunk/Hibernate3/src/org/hibernate/loader/custom/CustomLoader.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/loader/custom/CustomLoader.java 2006-06-14 00:31:15 UTC (rev 10017)
+++ trunk/Hibernate3/src/org/hibernate/loader/custom/CustomLoader.java 2006-06-15 05:21:06 UTC (rev 10018)
@@ -7,6 +7,9 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.HashSet;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
@@ -20,199 +23,308 @@
import org.hibernate.loader.EntityAliases;
import org.hibernate.loader.Loader;
import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.Loadable;
+import org.hibernate.persister.entity.Queryable;
import org.hibernate.transform.ResultTransformer;
import org.hibernate.type.Type;
import org.hibernate.type.TypeFactory;
+import org.hibernate.type.EntityType;
+import org.hibernate.type.CollectionType;
import org.hibernate.util.ArrayHelper;
/**
- * Extension point for loaders which use a SQL
- * result set with "unexpected" column aliases.
+ * Extension point for loaders which use a SQL result set with "unexpected" column aliases.
*
* @author Gavin King
+ * @author Steve Ebersole
*/
public class CustomLoader extends Loader {
// Currently *not* cachable if autodiscover types is in effect (e.g. "select * ...")
-
- private final Type[] resultTypes;
- private final Loadable[] persisters;
- private final CollectionPersister[] collectionPersisters;
- private final CustomQuery customQuery;
- private Type[] discoveredTypes;
- private String[] discoveredColumnAliases;
- private ResultSetMetaData metaData;
- private final String[] queryReturnAliases;
-
- public CustomLoader(
- CustomQuery customQuery,
- SessionFactoryImplementor factory) {
- super(factory);
- this.customQuery = customQuery;
-
- queryReturnAliases = customQuery.getReturnAliases();
-
- String[] collectionRoles = customQuery.getCollectionRoles();
- if ( collectionRoles==null ) {
- collectionPersisters = null;
- }
- else {
- int length = collectionRoles.length;
- collectionPersisters = new CollectionPersister[length];
- for ( int i=0; i<length; i++ ) {
- collectionPersisters[i] = factory.getCollectionPersister( collectionRoles[i] );
+
+ private final String sql;
+ private final Set querySpaces = new HashSet();
+ private final Map namedParameterBindPoints;
+
+ private final Queryable[] entityPersisters;
+ private final int[] entiytOwners;
+ private final EntityAliases[] entityAliases;
+
+ private final QueryableCollection[] collectionPersisters;
+ private final int[] collectionOwners;
+ private final CollectionAliases[] collectionAliases;
+
+ private final LockMode[] lockModes;
+// private final String[] sqlAliases;
+// private final String[] sqlAliasSuffixes;
+ private final ResultRowProcessor rowProcessor;
+
+ // this is only needed (afaict) for processing results from the query cache;
+ // however, this cannot possibly work in the case of discovered types...
+ private Type[] resultTypes;
+
+ // this is only needed (afaict) for ResultTransformer processing...
+ private String[] transformerAliases;
+
+
+ public CustomLoader(CustomQuery customQuery, SessionFactoryImplementor factory) {
+ super( factory );
+
+ this.sql = customQuery.getSQL();
+ this.querySpaces.addAll( customQuery.getQuerySpaces() );
+ this.namedParameterBindPoints = customQuery.getNamedParameterBindPoints();
+
+ List entityPersisters = new ArrayList();
+ List entityOwners = new ArrayList();
+ List entityAliases = new ArrayList();
+
+ List collectionPersisters = new ArrayList();
+ List collectionOwners = new ArrayList();
+ List collectionAliases = new ArrayList();
+
+ List lockModes = new ArrayList();
+ List resultColumnProcessors = new ArrayList();
+ List nonScalarReturnList = new ArrayList();
+ List resultTypes = new ArrayList();
+ List specifiedAliases = new ArrayList();
+ int returnableCounter = 0;
+ boolean hasScalars = false;
+
+ Iterator itr = customQuery.getCustomQueryReturns().iterator();
+ while ( itr.hasNext() ) {
+ final Return rtn = ( Return ) itr.next();
+ if ( rtn instanceof ScalarReturn ) {
+ ScalarReturn scalarRtn = ( ScalarReturn ) rtn;
+ resultColumnProcessors.add(
+ new ScalarResultColumnProcessor(
+ scalarRtn.getColumnAlias(),
+ scalarRtn.getType(),
+ resultTypes.size()
+ )
+ );
+ resultTypes.add( scalarRtn.getType() );
+ specifiedAliases.add( scalarRtn.getColumnAlias() );
+ hasScalars = true;
}
+ else if ( rtn instanceof RootReturn ) {
+ RootReturn rootRtn = ( RootReturn ) rtn;
+ Queryable persister = ( Queryable ) factory.getEntityPersister( rootRtn.getEntityName() );
+ entityPersisters.add( persister );
+ lockModes.add( rootRtn.getLockMode() );
+ resultColumnProcessors.add( new NonScalarResultColumnProcessor( returnableCounter++ ) );
+ nonScalarReturnList.add( rtn );
+ entityOwners.add( new Integer( -1 ) );
+ resultTypes.add( persister.getType() );
+ specifiedAliases.add( rootRtn.getAlias() );
+ entityAliases.add( rootRtn.getEntityAliases() );
+ ArrayHelper.addAll( querySpaces, persister.getQuerySpaces() );
+ }
+ else if ( rtn instanceof CollectionReturn ) {
+ CollectionReturn collRtn = ( CollectionReturn ) rtn;
+ String role = collRtn.getOwnerEntityName() + "." + collRtn.getOwnerProperty();
+ QueryableCollection persister = ( QueryableCollection ) factory.getCollectionPersister( role );
+ collectionPersisters.add( persister );
+ lockModes.add( collRtn.getLockMode() );
+ resultColumnProcessors.add( new NonScalarResultColumnProcessor( returnableCounter++ ) );
+ nonScalarReturnList.add( rtn );
+ collectionOwners.add( new Integer( -1 ) );
+ resultTypes.add( persister.getType() );
+ specifiedAliases.add( collRtn.getAlias() );
+ collectionAliases.add( collRtn.getCollectionAliases() );
+ // determine if the collection elements are entities...
+ Type elementType = persister.getElementType();
+ if ( elementType.isEntityType() ) {
+ Queryable element...
[truncated message content] |
|
From: <hib...@li...> - 2006-06-14 00:31:19
|
Author: epbernard
Date: 2006-06-13 20:31:15 -0400 (Tue, 13 Jun 2006)
New Revision: 10017
Modified:
trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java
Log:
ANN-373 add import for entityName, entityName. Tools relies on it
Modified: trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2006-06-13 23:54:54 UTC (rev 10016)
+++ trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2006-06-14 00:31:15 UTC (rev 10017)
@@ -201,6 +201,10 @@
log.debug( "Import with entity name=" + name );
try {
mappings.addImport( persistentClass.getEntityName(), name );
+ String entityName = persistentClass.getEntityName();
+ if ( ! entityName.equals( name ) ) {
+ mappings.addImport( entityName, entityName );
+ }
}
catch (MappingException me) {
throw new AnnotationException( "Use of the same entity name twice: " + name );
|
|
From: <hib...@li...> - 2006-06-12 17:01:19
|
Author: max...@jb...
Date: 2006-06-12 13:01:09 -0400 (Mon, 12 Jun 2006)
New Revision: 10015
Added:
trunk/HibernateExt/tools/src/templates/seam/components.xml.ftl
Modified:
trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/seam/SeamExporter.java
trunk/HibernateExt/tools/src/templates/seam/build.properties.ftl
trunk/HibernateExt/tools/src/templates/seam/persistence.xml.ftl
trunk/HibernateExt/tools/src/templates/seam/seam.properties.ftl
trunk/HibernateExt/tools/src/test/org/hibernate/tool/ant/SeamAntTest.java
trunk/HibernateExt/tools/src/testsupport/anttest-build.xml
trunk/HibernateExt/tools/src/testsupport/seamtest-build.xml
Log:
update seam templates to seam 1.0
Modified: trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/seam/SeamExporter.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/seam/SeamExporter.java 2006-06-12 16:56:27 UTC (rev 10014)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/seam/SeamExporter.java 2006-06-12 17:01:09 UTC (rev 10015)
@@ -46,6 +46,7 @@
configureExporter( "seam/build.xml.ftl", "build.xml").start();
configureExporter( "seam/build.properties.ftl", "build.properties").start();
+ configureExporter( "seam/components.xml.ftl", "resources/WEB-INF/components.xml").start();
configureExporter( "seam/readme.txt.ftl", "readme.txt").start();
new File( getOutputDirectory(), "lib" ).mkdir();
Modified: trunk/HibernateExt/tools/src/templates/seam/build.properties.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/seam/build.properties.ftl 2006-06-12 16:56:27 UTC (rev 10014)
+++ trunk/HibernateExt/tools/src/templates/seam/build.properties.ftl 2006-06-12 17:01:09 UTC (rev 10015)
@@ -1,2 +1,3 @@
##jboss.home = C:/jboss-4.0.4
-##jboss.home = C:/Projects/jboss-head/build/output/jboss-5.0.0alpha
\ No newline at end of file
+##jboss.home = C:/Projects/jboss-head/build/output/jboss-5.0.0alpha
+##jboss.home = c:/Program Files/jboss-4.0.4.GA
\ No newline at end of file
Added: trunk/HibernateExt/tools/src/templates/seam/components.xml.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/seam/components.xml.ftl 2006-06-12 16:56:27 UTC (rev 10014)
+++ trunk/HibernateExt/tools/src/templates/seam/components.xml.ftl 2006-06-12 17:01:09 UTC (rev 10015)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components>
+
+ <component name="org.jboss.seam.core.init">
+ <property name="myFacesLifecycleBug">true</property>
+ <property name="jndiPattern">${seam_shortname}/${'#'}{ejbName}/local</property>
+ </component>
+
+ <component name="entityManager" class="org.jboss.seam.core.ManagedPersistenceContext">
+ <property name="persistenceUnitJndiName">java:/${seam_shortname}EntityManagerFactory</property>
+ </component>
+
+ <!--
+ <component name="org.jboss.seam.core.manager">
+ <property name="conversationTimeout">120000</property>
+ </component>
+
+ <component class="org.jboss.seam.core.Ejb" installed="false"/>
+ -->
+
+</components>
\ No newline at end of file
Modified: trunk/HibernateExt/tools/src/templates/seam/persistence.xml.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/seam/persistence.xml.ftl 2006-06-12 16:56:27 UTC (rev 10014)
+++ trunk/HibernateExt/tools/src/templates/seam/persistence.xml.ftl 2006-06-12 17:01:09 UTC (rev 10015)
@@ -8,7 +8,7 @@
<property name="hibernate.transaction.flush_before_completion" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
- <property name="jboss.entity.manager.factory.jndi.name" value="java:/entityManager"/>
+ <property name="jboss.entity.manager.factory.jndi.name" value="java:/${seam_shortname}EntityManagerFactory"/>
</properties>
</persistence-unit>
</entity-manager>
\ No newline at end of file
Modified: trunk/HibernateExt/tools/src/templates/seam/seam.properties.ftl
===================================================================
--- trunk/HibernateExt/tools/src/templates/seam/seam.properties.ftl 2006-06-12 16:56:27 UTC (rev 10014)
+++ trunk/HibernateExt/tools/src/templates/seam/seam.properties.ftl 2006-06-12 17:01:09 UTC (rev 10015)
@@ -1,4 +1,4 @@
# seam.properties
-org.jboss.seam.core.init.managedPersistenceContexts entityManager
+#org.jboss.seam.core.init.managedPersistenceContexts entityManager
#org.jboss.seam.core.manager.conversationTimeout 30000
-org.jboss.seam.core.init.jndiPattern seamapp/#\{ejbName\}/local
\ No newline at end of file
+#org.jboss.seam.core.init.jndiPattern seamapp/#\{ejbName\}/local
\ No newline at end of file
Modified: trunk/HibernateExt/tools/src/test/org/hibernate/tool/ant/SeamAntTest.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/ant/SeamAntTest.java 2006-06-12 16:56:27 UTC (rev 10014)
+++ trunk/HibernateExt/tools/src/test/org/hibernate/tool/ant/SeamAntTest.java 2006-06-12 17:01:09 UTC (rev 10015)
@@ -35,7 +35,6 @@
protected void tearDown() throws Exception {
- //assertEquals("Method not found errors during template processing:\n " + HibernateUberspect.getMethodErrors(),0,HibernateUberspect.getMethodNotFoundCount());
System.out.println(getLog() );
}
@@ -51,6 +50,7 @@
assertFileAndExists(new File(baseDir, "build.xml"));
assertFileAndExists(new File(baseDir, "resources/seam.properties"));
+ assertFileAndExists(new File(baseDir, "resources/WEB-INF/components.xml"));
validXMLFile( new File(baseDir, "resources/WEB-INF/web.xml") );
Modified: trunk/HibernateExt/tools/src/testsupport/anttest-build.xml
===================================================================
--- trunk/HibernateExt/tools/src/testsupport/anttest-build.xml 2006-06-12 16:56:27 UTC (rev 10014)
+++ trunk/HibernateExt/tools/src/testsupport/anttest-build.xml 2006-06-12 17:01:09 UTC (rev 10015)
@@ -236,7 +236,6 @@
<target name="prepareCfg2hbm" description="prepare for cfg2hbm tasks">
<sql onerror="continue" driver="${hibernate.connection.driver_class}" url="${hibernate.connection.url}" userid="${hibernate.connection.username}" password="${hibernate.connection.password}" classpath="${hibernate-core.home}\jdbc\hsqldb.jar">
create table VeriSimplyTable ( id bigint not null, name varchar(255), primary key (id) );
- SHUTDOWN;
</sql>
<delete dir="${build.dir}/cfg2hbm" failonerror="false" />
@@ -246,7 +245,6 @@
<target name="afterCfg2hbm" description="prepare for cfg2hbm tasks">
<sql onerror="continue" driver="${hibernate.connection.driver_class}" url="${hibernate.connection.url}" userid="${hibernate.connection.username}" password="${hibernate.connection.password}" classpath="${hibernate-core.home}\jdbc\hsqldb.jar">
drop table VeriSimplyTable;
- SHUTDOWN;
</sql>
</target>
Modified: trunk/HibernateExt/tools/src/testsupport/seamtest-build.xml
===================================================================
--- trunk/HibernateExt/tools/src/testsupport/seamtest-build.xml 2006-06-12 16:56:27 UTC (rev 10014)
+++ trunk/HibernateExt/tools/src/testsupport/seamtest-build.xml 2006-06-12 17:01:09 UTC (rev 10015)
@@ -5,7 +5,7 @@
<property name="build.dir" location="../../build/seamtest"/>
<property file="../../etc/hibernate.properties"/>
- <delete dir="${build.dir}"/>
+<!-- <delete dir="${build.dir}"/> -->
<property name="destdir" location="${build.dir}/crud"/>
|
Author: epbernard
Date: 2006-06-12 12:56:27 -0400 (Mon, 12 Jun 2006)
New Revision: 10014
Added:
trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java
Modified:
trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java
trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/lucene/Document.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/lucene/LuceneTest.java
Log:
ANN-370 thread safe
ANN-371 abstract for the Directory implementation
ANN-372 @Boost
Added: trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java 2006-06-11 17:00:19 UTC (rev 10013)
+++ trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/Boost.java 2006-06-12 16:56:27 UTC (rev 10014)
@@ -0,0 +1,20 @@
+//$Id: $
+package org.hibernate.lucene;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Documented;
+
+/**
+ * Apply a boost factor on a field or a whole entity
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Documented
+public @interface Boost {
+ float value();
+}
Modified: trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java 2006-06-11 17:00:19 UTC (rev 10013)
+++ trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/DocumentBuilder.java 2006-06-12 16:56:27 UTC (rev 10014)
@@ -1,20 +1,21 @@
//$Id$
package org.hibernate.lucene;
-import java.io.File;
+import java.beans.Introspector;
import java.io.Serializable;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.lang.reflect.AnnotatedElement;
import java.util.ArrayList;
import java.util.List;
-import java.beans.Introspector;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.Term;
+import org.apache.lucene.store.Directory;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.cfg.annotations.Version;
@@ -34,15 +35,15 @@
private final List<String> textNames = new ArrayList<String>();
//private final Class<T> beanClass;
- private final File file;
+ private final Directory directory;
private String idKeywordName;
private final Analyzer analyzer;
+ private Float idBoost;
- public DocumentBuilder(Class<?> clazz, Analyzer analyzer, File indexDir) {
+ public DocumentBuilder(Class<?> clazz, Analyzer analyzer, Directory directory) {
//this.beanClass = clazz;
this.analyzer = analyzer;
- String fileName = getTypeName( clazz, ( clazz.getAnnotation( Indexed.class ) ).index() );
- file = new File( indexDir, fileName );
+ this.directory = directory;
for ( Class currClass = clazz; currClass != null ; currClass = currClass.getSuperclass() ) {
Method[] methods = currClass.getDeclaredMethods();
@@ -53,6 +54,7 @@
String name = getAttributeName( method, keywordAnn.name() );
if ( keywordAnn.id() ) {
idKeywordName = name;
+ idBoost = getBoost( method );
}
else {
setAccessible( method );
@@ -79,6 +81,12 @@
}
}
+ private Float getBoost(AnnotatedElement element) {
+ if (element == null) return null;
+ Boost boost = element.getAnnotation( Boost.class );
+ return boost != null ? new Float( boost.value() ) : null;
+ }
+
private Object getValue(Member member, T bean) {
try {
if ( member instanceof java.lang.reflect.Field ) {
@@ -98,30 +106,53 @@
public Document getDocument(T instance, Serializable id) {
Document doc = new Document();
- doc.add( new Field( idKeywordName, id.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED ) );
+ Float boost = getBoost( instance.getClass() );
+ if (boost != null) {
+ doc.setBoost( boost.floatValue() );
+ }
+ {
+ Field idField = new Field( idKeywordName, id.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED );
+ if (idBoost != null) {
+ idField.setBoost( idBoost.floatValue() );
+ }
+ doc.add( idField );
+ }
for ( int i = 0; i < keywordNames.size() ; i++ ) {
Member member = keywordGetters.get( i );
Object value = getValue( member, instance );
if ( value != null ) {
- doc.add( new Field( keywordNames.get( i ), toString( value ), Field.Store.YES, Field.Index.UN_TOKENIZED ) );
+ Field field = new Field( keywordNames.get( i ), toString( value ), Field.Store.YES, Field.Index.UN_TOKENIZED );
+ boostField(field, member);
+ doc.add( field );
}
}
for ( int i = 0; i < textNames.size() ; i++ ) {
- Object value = getValue( textGetters.get( i ), instance );
+ Member member = textGetters.get( i );
+ Object value = getValue( member, instance );
if ( value != null ) {
- doc.add( new Field( textNames.get( i ), toString( value ), Field.Store.YES, Field.Index.TOKENIZED) );
+ Field field = new Field( textNames.get( i ), toString( value ), Field.Store.YES, Field.Index.TOKENIZED );
+ boostField(field, member);
+ doc.add( field );
}
}
for ( int i = 0; i < unstoredNames.size() ; i++ ) {
- Object value = getValue( unstoredGetters.get( i ), instance );
+ Member member = unstoredGetters.get( i );
+ Object value = getValue( member, instance );
if ( value != null ) {
- doc.add( new Field( unstoredNames.get( i ), toString( value ), Field.Store.NO, Field.Index.TOKENIZED ) );
+ Field field = new Field( unstoredNames.get( i ), toString( value ), Field.Store.NO, Field.Index.TOKENIZED );
+ boostField(field, member);
+ doc.add( field );
}
}
return doc;
}
+ private void boostField(Field field, Member member) {
+ Float boost = getBoost( (AnnotatedElement) member );
+ if (boost != null) field.setBoost( boost.floatValue() );
+ }
+
private static String toString(Object value) {
return value.toString();
}
@@ -143,14 +174,10 @@
return Introspector.decapitalize( methodName.substring( startIndex ) );
}
- private static String getTypeName(Class clazz, String name) {
- return "".equals( name ) ? clazz.getName() : name;
+ public Directory getDirectory() {
+ return directory;
}
- public File getFile() {
- return file;
- }
-
public Analyzer getAnalyzer() {
return analyzer;
}
Modified: trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java 2006-06-11 17:00:19 UTC (rev 10013)
+++ trunk/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java 2006-06-12 16:56:27 UTC (rev 10014)
@@ -7,6 +7,8 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -16,6 +18,8 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
import org.hibernate.event.Initializable;
@@ -38,10 +42,13 @@
* @author Emmanuel Bernard
* @author Mattias Arbin
*/
+//TODO takes care of synchronization and index concurrent index change
public class LuceneEventListener implements PostDeleteEventListener, PostInsertEventListener,
PostUpdateEventListener, Initializable {
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 */
+ private Map<Directory, Lock> indexLock = new HashMap<Directory, Lock>();
private boolean initialized;
private static final Log log = LogFactory.getLog( LuceneEventListener.class );
@@ -92,8 +99,26 @@
PersistentClass clazz = (PersistentClass) iter.next();
Class<?> mappedClass = clazz.getMappedClass();
if ( mappedClass != null ) {
- if ( mappedClass.getAnnotation( Indexed.class ) != null ) {
- final DocumentBuilder<Object> documentBuilder = new DocumentBuilder<Object>( mappedClass, analyzer, indexDir );
+ if ( mappedClass.isAnnotationPresent( Indexed.class ) ) {
+ Indexed indexed = mappedClass.getAnnotation( Indexed.class );
+ String fileName = getTypeName( mappedClass, indexed.index() );
+ File file = new File( indexDir, fileName );
+ Directory directory;
+ try {
+ boolean create = !file.exists();
+ directory = FSDirectory.getDirectory( file.getCanonicalPath(), create );
+ if (create) {
+ IndexWriter iw = new IndexWriter(directory, new StandardAnalyzer(), create );
+ iw.close();
+ }
+ }
+ catch (IOException ie) {
+ throw new HibernateException("Unable to initialize index: " + indexed.index(), ie );
+ }
+ final DocumentBuilder<Object> documentBuilder = new DocumentBuilder<Object>( mappedClass, analyzer, directory );
+ if ( ! indexLock.containsKey( directory ) ) {
+ indexLock.put( directory, new ReentrantLock() );
+ }
documentBuilders.put( mappedClass, documentBuilder );
// try {
// IndexWriter iw = new IndexWriter( documentBuilder.getFile(), new StopAnalyzer(), true );
@@ -102,13 +127,17 @@
// catch (IOException ioe) {
// throw new HibernateException(ioe);
// }
- log.info( "index: " + documentBuilder.getFile().getAbsolutePath() );
+ log.info( "index file: " + file.getAbsolutePath() );
}
}
}
initialized = true;
}
+ private static String getTypeName(Class clazz, String name) {
+ return "".equals( name ) ? clazz.getName() : name;
+ }
+
public void onPostDelete(PostDeleteEvent event) {
DocumentBuilder builder = documentBuilders.get( event.getEntity().getClass() );
if ( builder != null ) {
@@ -137,14 +166,21 @@
private void remove(DocumentBuilder<?> builder, Serializable id) {
Term term = builder.getTerm( id );
log.debug( "removing: " + term );
+ Directory directory = builder.getDirectory();
+ Lock lock = indexLock.get( directory );
+ lock.lock();
try {
- IndexReader reader = IndexReader.open( builder.getFile() );
+
+ IndexReader reader = IndexReader.open( directory );
reader.deleteDocuments( term );
reader.close();
}
catch (IOException ioe) {
throw new HibernateException( ioe );
}
+ finally {
+ lock.unlock();
+ }
}
private void add(final Object entity, final DocumentBuilder<Object> builder, final Serializable id) {
@@ -152,15 +188,20 @@
if( log.isDebugEnabled() ) {
log.debug( "adding: " + doc );
}
+ Directory directory = builder.getDirectory();
+ Lock lock = indexLock.get( directory );
+ lock.lock();
try {
- File file = builder.getFile();
- IndexWriter writer = new IndexWriter( file, builder.getAnalyzer(), ! file.exists() );
+ IndexWriter writer = new IndexWriter( directory, builder.getAnalyzer(), false); //have been created at init time
writer.addDocument( doc );
writer.close();
}
catch (IOException ioe) {
throw new HibernateException( ioe );
}
+ finally {
+ lock.unlock();
+ }
}
}
Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/lucene/Document.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/lucene/Document.java 2006-06-11 17:00:19 UTC (rev 10013)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/lucene/Document.java 2006-06-12 16:56:27 UTC (rev 10014)
@@ -10,6 +10,7 @@
import org.hibernate.lucene.Keyword;
import org.hibernate.lucene.Text;
import org.hibernate.lucene.Unstored;
+import org.hibernate.lucene.Boost;
@Entity
@Indexed(index = "Documents")
@@ -41,6 +42,7 @@
}
@Text
+ @Boost(2)
public String getTitle() {
return title;
}
Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/lucene/LuceneTest.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/lucene/LuceneTest.java 2006-06-11 17:00:19 UTC (rev 10013)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/lucene/LuceneTest.java 2006-06-12 16:56:27 UTC (rev 10014)
@@ -2,13 +2,18 @@
package org.hibernate.test.lucene;
import java.io.File;
+import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermDocs;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Hits;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.event.PostDeleteEventListener;
@@ -70,16 +75,20 @@
s.close();
IndexReader reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
- int num = reader.numDocs();
- assertEquals( 1, num );
- TermDocs docs = reader.termDocs( new Term( "Abstract", "Hibernate" ) );
- org.apache.lucene.document.Document doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- docs = reader.termDocs( new Term( "Title", "Action" ) );
- doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- assertEquals( "1", doc.getField( "id" ).stringValue() );
- reader.close();
+ try {
+ int num = reader.numDocs();
+ assertEquals( 1, num );
+ TermDocs docs = reader.termDocs( new Term( "Abstract", "Hibernate" ) );
+ org.apache.lucene.document.Document doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ docs = reader.termDocs( new Term( "Title", "Action" ) );
+ doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ assertEquals( "1", doc.getField( "id" ).stringValue() );
+ }
+ finally {
+ reader.close();
+ }
s = getSessions().openSession();
s.getTransaction().begin();
@@ -90,12 +99,16 @@
s.close();
reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
- num = reader.numDocs();
- assertEquals( 2, num );
- docs = reader.termDocs( new Term( "Abstract", "EJB3" ) );
- doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- reader.close();
+ try {
+ int num = reader.numDocs();
+ assertEquals( 2, num );
+ TermDocs docs = reader.termDocs( new Term( "Abstract", "EJB3" ) );
+ org.apache.lucene.document.Document doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ }
+ finally {
+ reader.close();
+ }
s = getSessions().openSession();
s.getTransaction().begin();
@@ -104,13 +117,17 @@
s.close();
reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
- num = reader.numDocs();
- assertEquals( 1, num );
- docs = reader.termDocs( new Term( "Title", "Seam" ) );
- doc = reader.document( docs.doc() );
- assertFalse( docs.next() );
- assertEquals( "2", doc.getField( "id" ).stringValue() );
- reader.close();
+ try {
+ int num = reader.numDocs();
+ assertEquals( 1, num );
+ TermDocs docs = reader.termDocs( new Term( "Title", "Seam" ) );
+ org.apache.lucene.document.Document doc = reader.document( docs.doc() );
+ assertFalse( docs.next() );
+ assertEquals( "2", doc.getField( "id" ).stringValue() );
+ }
+ finally {
+ reader.close();
+ }
s = getSessions().openSession();
s.getTransaction().begin();
@@ -119,6 +136,43 @@
s.close();
}
+ public void testBoost() throws Exception {
+
+
+ Session s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.persist(
+ new Document( "Hibernate in Action", "Object and Relational", "blah blah blah" )
+ );
+ s.persist(
+ new Document( "Object and Relational", "Hibernate in Action", "blah blah blah" )
+ );
+ s.getTransaction().commit();
+ s.close();
+
+ IndexSearcher searcher = new IndexSearcher( new File( getBaseIndexDir(), "Documents" ).getCanonicalPath() );
+ try {
+ QueryParser qp = new QueryParser("id", new StandardAnalyzer() );
+ Hits hits = searcher.search( qp.parse("title:Action OR Abstract:Action") );
+ assertEquals( 2, hits.length() );
+ assertTrue( hits.score( 0 ) == 2*hits.score( 1 ) );
+ assertEquals( "Hibernate in Action", hits.doc(0).get( "title") );
+ }
+ finally {
+ if (searcher != null) searcher.close();
+ }
+
+
+ s = getSessions().openSession();
+ s.getTransaction().begin();
+ List list = s.createQuery( "from Document" ).list();
+ for (Document document : (List<Document>) list) {
+ s.delete( document );
+ }
+ s.getTransaction().commit();
+ s.close();
+ }
+
protected Class[] getMappings() {
return new Class[]{Document.class};
}
|
|
From: <hib...@li...> - 2006-06-11 17:00:45
|
Author: gav...@jb... Date: 2006-06-11 13:00:19 -0400 (Sun, 11 Jun 2006) New Revision: 10013 Modified: trunk/Hibernate3/src/org/hibernate/transaction/JDBCTransactionFactory.java Log: clean imports Modified: trunk/Hibernate3/src/org/hibernate/transaction/JDBCTransactionFactory.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/transaction/JDBCTransactionFactory.java 2006-06-11 16:59:35 UTC (rev 10012) +++ trunk/Hibernate3/src/org/hibernate/transaction/JDBCTransactionFactory.java 2006-06-11 17:00:19 UTC (rev 10013) @@ -2,11 +2,10 @@ package org.hibernate.transaction; import java.util.Properties; -import java.sql.SQLException; import org.hibernate.ConnectionReleaseMode; -import org.hibernate.Transaction; import org.hibernate.HibernateException; +import org.hibernate.Transaction; import org.hibernate.jdbc.JDBCContext; /** |
|
From: <hib...@li...> - 2006-06-11 16:59:42
|
Author: gav...@jb...
Date: 2006-06-11 12:59:35 -0400 (Sun, 11 Jun 2006)
New Revision: 10012
Modified:
trunk/Hibernate3/src/org/hibernate/transaction/JTATransactionFactory.java
Log:
fix HHH-1827
Modified: trunk/Hibernate3/src/org/hibernate/transaction/JTATransactionFactory.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/transaction/JTATransactionFactory.java 2006-06-11 05:17:34 UTC (rev 10011)
+++ trunk/Hibernate3/src/org/hibernate/transaction/JTATransactionFactory.java 2006-06-11 16:59:35 UTC (rev 10012)
@@ -82,8 +82,8 @@
try {
ut = ( UserTransaction ) context.lookup( utName );
}
- catch ( NamingException e ) {
- throw new TransactionException( "Unable to locate UserTransaction to check status" );
+ catch ( NamingException ne ) {
+ throw new TransactionException( "Unable to locate UserTransaction to check status", ne );
}
}
return ut != null && JTAHelper.isInProgress( ut.getStatus() );
|
|
From: <hib...@li...> - 2006-06-11 05:17:44
|
Author: epbernard
Date: 2006-06-11 01:17:34 -0400 (Sun, 11 Jun 2006)
New Revision: 10011
Modified:
trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/transaction/JoinableCMTTransaction.java
Log:
EJB-198 always ckeck for rx not marked for rollback
Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/transaction/JoinableCMTTransaction.java
===================================================================
--- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/transaction/JoinableCMTTransaction.java 2006-06-11 03:50:42 UTC (rev 10010)
+++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/transaction/JoinableCMTTransaction.java 2006-06-11 05:17:34 UTC (rev 10011)
@@ -31,7 +31,7 @@
TransactionFactory.Context transactionContext
) {
try {
- return status == JoinStatus.JOINED && JTAHelper.isTransactionInProgress(
+ return status == JoinStatus.JOINED && isTransactionInProgress(
transactionContext.getFactory().getTransactionManager().getTransaction()
);
}
@@ -43,15 +43,17 @@
private boolean isTransactionInProgress() {
try {
Transaction transaction = transactionContext.getFactory().getTransactionManager().getTransaction();
- return JTAHelper.isTransactionInProgress(
- transaction
- ) && ! JTAHelper.isRollback( transaction.getStatus() );
+ return isTransactionInProgress(transaction);
}
catch (SystemException se) {
throw new TransactionException( "Unable to check transaction status", se );
}
}
+ private boolean isTransactionInProgress(Transaction tx) throws SystemException {
+ return JTAHelper.isTransactionInProgress(tx) && ! JTAHelper.isRollback( tx.getStatus() );
+ }
+
void tryJoiningTransaction() {
if ( status == JoinStatus.MARKED_FOR_JOINED ) {
if ( isTransactionInProgress() ) {
|