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-03-20 14:01:46
|
Author: ste...@jb... Date: 2006-03-20 09:01:35 -0500 (Mon, 20 Mar 2006) New Revision: 9660 Modified: branches/Branch_3_1/Hibernate3/src/org/hibernate/type/NullableType.java Log: HHH-1453 : exception handling on get/set Modified: branches/Branch_3_1/Hibernate3/src/org/hibernate/type/NullableType.java =================================================================== --- branches/Branch_3_1/Hibernate3/src/org/hibernate/type/NullableType.java 2006-03-20 14:01:19 UTC (rev 9659) +++ branches/Branch_3_1/Hibernate3/src/org/hibernate/type/NullableType.java 2006-03-20 14:01:35 UTC (rev 9660) @@ -6,6 +6,7 @@ import java.sql.SQLException; import org.apache.commons.logging.LogFactory; +import org.apache.commons.logging.Log; import org.dom4j.Node; import org.hibernate.EntityMode; @@ -25,15 +26,16 @@ private static final boolean IS_TRACE_ENABLED; static { - //cache this, because it was a significant performance cost + //cache this, because it was a significant performance cost; is + // trace logging enabled on the type package... IS_TRACE_ENABLED = LogFactory.getLog( StringHelper.qualifier( Type.class.getName() ) ).isTraceEnabled(); } - + /** * Get a column value from a result set, without worrying about the * possibility of null values */ - public abstract Object get(ResultSet rs, String name) + public abstract Object get(ResultSet rs, String name) throws HibernateException, SQLException; /** @@ -66,37 +68,27 @@ public final void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { try { - if (value==null) { - if (IS_TRACE_ENABLED) { - LogFactory.getLog( getClass() ) - .trace("binding null to parameter: " + index); + if ( value == null ) { + if ( IS_TRACE_ENABLED ) { + log().trace( "binding null to parameter: " + index ); } st.setNull( index, sqlType() ); } else { - if (IS_TRACE_ENABLED) { - LogFactory.getLog( getClass() ).trace( - "binding '" + toString(value) + - "' to parameter: " + index - ); + if ( IS_TRACE_ENABLED ) { + log().trace( "binding '" + toString( value ) + "' to parameter: " + index ); } - set(st, value, index); + set( st, value, index ); } } - catch (RuntimeException re) { - LogFactory.getLog( getClass() ).info( - "could not bind value '" + toString(value) + - "' to parameter: " + index - ); + catch ( RuntimeException re ) { + log().info( "could not bind value '" + toString( value ) + "' to parameter: " + index + "; " + re.getMessage() ); throw re; } - catch (SQLException se) { - LogFactory.getLog( getClass() ).info( - "could not bind value '" + toString(value) + - "' to parameter: " + index - ); + catch ( SQLException se ) { + log().info( "could not bind value '" + toString( value ) + "' to parameter: " + index + "; " + se.getMessage() ); throw se; } } @@ -119,31 +111,25 @@ throws HibernateException, SQLException { try { Object value = get(rs, name); - if ( value==null || rs.wasNull() ) { - if (IS_TRACE_ENABLED) { - LogFactory.getLog( getClass() ) - .trace("returning null as column: " + name); + if ( value == null || rs.wasNull() ) { + if ( IS_TRACE_ENABLED ) { + log().trace( "returning null as column: " + name ); } return null; } else { if (IS_TRACE_ENABLED) { - LogFactory.getLog( getClass() ).trace( - "returning '" + toString(value) + - "' as column: " + name - ); + log().trace( "returning '" + toString( value ) + "' as column: " + name ); } return value; } } - catch (RuntimeException re) { - LogFactory.getLog( getClass() ) - .info("could not read column value from result set: " + name); + catch ( RuntimeException re ) { + log().info( "could not read column value from result set: " + name + "; " + re.getMessage() ); throw re; } - catch (SQLException se) { - LogFactory.getLog( getClass() ) - .info("could not read column value from result set: " + name); + catch ( SQLException se ) { + log().info( "could not read column value from result set: " + name + "; " + se.getMessage() ); throw se; } } @@ -200,4 +186,7 @@ return checkable[0] && isDirty(old, current, session); } + private Log log() { + return LogFactory.getLog( getClass() ); + } } |
From: <hib...@li...> - 2006-03-20 14:01:28
|
Author: ste...@jb... Date: 2006-03-20 09:01:19 -0500 (Mon, 20 Mar 2006) New Revision: 9659 Modified: trunk/Hibernate3/src/org/hibernate/type/NullableType.java Log: HHH-1453 : exception handling on get/set Modified: trunk/Hibernate3/src/org/hibernate/type/NullableType.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/type/NullableType.java 2006-03-19 04:07:05 UTC (rev 9658) +++ trunk/Hibernate3/src/org/hibernate/type/NullableType.java 2006-03-20 14:01:19 UTC (rev 9659) @@ -6,6 +6,7 @@ import java.sql.SQLException; import org.apache.commons.logging.LogFactory; +import org.apache.commons.logging.Log; import org.dom4j.Node; import org.hibernate.EntityMode; @@ -25,122 +26,120 @@ private static final boolean IS_TRACE_ENABLED; static { - //cache this, because it was a significant performance cost + //cache this, because it was a significant performance cost; is + // trace logging enabled on the type package... IS_TRACE_ENABLED = LogFactory.getLog( StringHelper.qualifier( Type.class.getName() ) ).isTraceEnabled(); } - + /** - * Get a column value from a result set, without worrying about the + * Get a column value from a result set, without worrying about the * possibility of null values */ - public abstract Object get(ResultSet rs, String name) + public abstract Object get(ResultSet rs, String name) throws HibernateException, SQLException; - + /** * Get a parameter value without worrying about the possibility of null values */ - public abstract void set(PreparedStatement st, Object value, int index) + public abstract void set(PreparedStatement st, Object value, int index) throws HibernateException, SQLException; - + public abstract int sqlType(); - + public abstract String toString(Object value) throws HibernateException; - + public abstract Object fromStringValue(String xml) throws HibernateException; public final void nullSafeSet( - PreparedStatement st, - Object value, - int index, - boolean[] settable, - SessionImplementor session) + PreparedStatement st, + Object value, + int index, + boolean[] settable, + SessionImplementor session) throws HibernateException, SQLException { if ( settable[0] ) nullSafeSet(st, value, index); } - public final void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) + public final void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { nullSafeSet(st, value, index); } - public final void nullSafeSet(PreparedStatement st, Object value, int index) + public final void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { try { - if (value==null) { - if (IS_TRACE_ENABLED) { - LogFactory.getLog( getClass() ) - .trace("binding null to parameter: " + index); + if ( value == null ) { + if ( IS_TRACE_ENABLED ) { + log().trace( "binding null to parameter: " + index ); } - + st.setNull( index, sqlType() ); } else { - if (IS_TRACE_ENABLED) { - LogFactory.getLog( getClass() ).trace( - "binding '" + toString(value) + - "' to parameter: " + index - ); + if ( IS_TRACE_ENABLED ) { + log().trace( "binding '" + toString( value ) + "' to parameter: " + index ); } - - set(st, value, index); + + set( st, value, index ); } } - catch (RuntimeException re) { - LogFactory.getLog( getClass() ).info( - "could not bind value '" + toString(value) + - "' to parameter: " + index - ); + catch ( RuntimeException re ) { + log().info( "could not bind value '" + toString( value ) + "' to parameter: " + index + "; " + re.getMessage() ); + throw re; } + catch ( SQLException se ) { + log().info( "could not bind value '" + toString( value ) + "' to parameter: " + index + "; " + se.getMessage() ); + throw se; + } } public final Object nullSafeGet( - ResultSet rs, - String[] names, - SessionImplementor session, - Object owner) + ResultSet rs, + String[] names, + SessionImplementor session, + Object owner) throws HibernateException, SQLException { return nullSafeGet(rs, names[0]); } - public final Object nullSafeGet(ResultSet rs, String[] names) + public final Object nullSafeGet(ResultSet rs, String[] names) throws HibernateException, SQLException { return nullSafeGet(rs, names[0]); } - public final Object nullSafeGet(ResultSet rs, String name) + public final Object nullSafeGet(ResultSet rs, String name) throws HibernateException, SQLException { try { Object value = get(rs, name); - if ( value==null || rs.wasNull() ) { - if (IS_TRACE_ENABLED) { - LogFactory.getLog( getClass() ) - .trace("returning null as column: " + name); + if ( value == null || rs.wasNull() ) { + if ( IS_TRACE_ENABLED ) { + log().trace( "returning null as column: " + name ); } return null; } else { if (IS_TRACE_ENABLED) { - LogFactory.getLog( getClass() ).trace( - "returning '" + toString(value) + - "' as column: " + name - ); + log().trace( "returning '" + toString( value ) + "' as column: " + name ); } return value; } } - catch (RuntimeException re) { - LogFactory.getLog( getClass() ) - .info("could not read column value from result set: " + name); + catch ( RuntimeException re ) { + log().info( "could not read column value from result set: " + name + "; " + re.getMessage() ); throw re; } + catch ( SQLException se ) { + log().info( "could not read column value from result set: " + name + "; " + se.getMessage() ); + throw se; + } } - public final Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) + public final Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) throws HibernateException, SQLException { return nullSafeGet(rs, name); } - public final String toXMLString(Object value, SessionFactoryImplementor pc) + public final String toXMLString(Object value, SessionFactoryImplementor pc) throws HibernateException { return toString(value); } @@ -156,11 +155,11 @@ public final int[] sqlTypes(Mapping session) { return new int[] { sqlType() }; } - + public final boolean isEqual(Object x, Object y, EntityMode entityMode) { return isEqual(x, y); } - + public boolean isEqual(Object x, Object y) { return EqualsHelper.equals(x, y); } @@ -173,18 +172,21 @@ return fromXMLString( xml.getText(), factory ); } - public void setToXMLNode(Node xml, Object value, SessionFactoryImplementor factory) + public void setToXMLNode(Node xml, Object value, SessionFactoryImplementor factory) throws HibernateException { xml.setText( toXMLString(value, factory) ); } - + public boolean[] toColumnNullness(Object value, Mapping mapping) { return value==null ? ArrayHelper.FALSE : ArrayHelper.TRUE; } - - public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) + + public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) throws HibernateException { return checkable[0] && isDirty(old, current, session); } + private Log log() { + return LogFactory.getLog( getClass() ); + } } |
From: Noviar S. <no...@gm...> - 2006-03-20 02:08:36
|
From: <hib...@li...> - 2006-03-19 04:07:08
|
Author: ste...@jb... Date: 2006-03-18 23:07:05 -0500 (Sat, 18 Mar 2006) New Revision: 9658 Added: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/EntityPersisterReference.java branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/PersisterReference.java branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/PropertyReference.java Log: initial persister/property ref nodes Added: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/EntityPersisterReference.java =================================================================== --- branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/EntityPersisterReference.java 2006-03-19 03:17:18 UTC (rev 9657) +++ branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/EntityPersisterReference.java 2006-03-19 04:07:05 UTC (rev 9658) @@ -0,0 +1,40 @@ +package org.hibernate.hql.ast.tree; + +import org.hibernate.type.AssociationType; +import org.hibernate.persister.entity.Queryable; + +/** + * @author Steve Ebersole + */ +public class EntityPersisterReference extends Node implements PersisterReference { + private String entityName; + private String alias; + private Queryable persister; + + public void initialize(String entityName, String alias) { + // todo : would much prefer this stuff to be constructor injection... + // todo : need a SF reference to resolve the persister... + this.entityName = entityName; + this.alias = alias; + } + + public String getName() { + return alias == null ? entityName : entityName + " (" + alias + ")"; + } + + public String getAlias() { + return alias; + } + + public AssociationType getPersisterType() { + return ( AssociationType ) persister.getType(); + } + + public PropertyReference retrievePropertyReference(String propertyName) { + return null; + } + + public String getDisplayText() { + return null; + } +} Added: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/PersisterReference.java =================================================================== --- branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/PersisterReference.java 2006-03-19 03:17:18 UTC (rev 9657) +++ branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/PersisterReference.java 2006-03-19 04:07:05 UTC (rev 9658) @@ -0,0 +1,17 @@ +package org.hibernate.hql.ast.tree; + +import org.hibernate.type.AssociationType; + +/** + * Represents a reference to a persister (either entity or collection) within + * an HQL statement. + * + * @author Steve Ebersole + */ +public interface PersisterReference extends DisplayableNode { + public String getName(); + public String getAlias(); + public AssociationType getPersisterType(); + + public PropertyReference retrievePropertyReference(String propertyName); +} Added: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/PropertyReference.java =================================================================== --- branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/PropertyReference.java 2006-03-19 03:17:18 UTC (rev 9657) +++ branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/PropertyReference.java 2006-03-19 04:07:05 UTC (rev 9658) @@ -0,0 +1,15 @@ +package org.hibernate.hql.ast.tree; + +import org.hibernate.type.Type; + +/** + * Represents a reference to a particular persister-managed property; also + * some special cases such as a collection property reference (e.g., size). + * + * @author Steve Ebersole + */ +public interface PropertyReference extends DisplayableNode { + public String getPropertyName(); + public Type getPropertyType(); + public PersisterReference getPersisterReference(); +} |
From: <hib...@li...> - 2006-03-19 03:17:20
|
Author: ste...@jb... Date: 2006-03-18 22:17:18 -0500 (Sat, 18 Mar 2006) New Revision: 9657 Modified: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinSource.java branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinType.java Log: minor Modified: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinSource.java =================================================================== --- branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinSource.java 2006-03-19 03:15:00 UTC (rev 9656) +++ branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinSource.java 2006-03-19 03:17:18 UTC (rev 9657) @@ -5,6 +5,8 @@ /** * Represents the source of a join, in the context of the HQL query. + * + * @author Steve Ebersole */ public class JoinSource implements Serializable { Modified: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinType.java =================================================================== --- branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinType.java 2006-03-19 03:15:00 UTC (rev 9656) +++ branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinType.java 2006-03-19 03:17:18 UTC (rev 9657) @@ -12,6 +12,8 @@ * start allowing users to specify ad-hoc joins this may need to change to * allow the full spectrum of join types. Thus the others are provided here * currently just for completeness and for future expansion. + * + * @author Steve Ebersole */ public class JoinType implements Serializable { /** |
From: <hib...@li...> - 2006-03-19 03:15:04
|
Author: ste...@jb... Date: 2006-03-18 22:15:00 -0500 (Sat, 18 Mar 2006) New Revision: 9656 Modified: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinNode.java Log: todo comment Modified: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinNode.java =================================================================== --- branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinNode.java 2006-03-19 03:13:00 UTC (rev 9655) +++ branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinNode.java 2006-03-19 03:15:00 UTC (rev 9656) @@ -11,6 +11,10 @@ */ public class JoinNode extends Node { + // todo : we need to decide the tree structure of a join subtree. + // based on that decision, we may need to have references here + // to both the left-hand and right-hand persister references + private JoinType joinType; private JoinSource source; private boolean fetch; |
From: <hib...@li...> - 2006-03-19 03:13:07
|
Author: ste...@jb... Date: 2006-03-18 22:13:00 -0500 (Sat, 18 Mar 2006) New Revision: 9655 Added: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinNode.java branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinSource.java branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinType.java Log: initial join related classes Added: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinNode.java =================================================================== --- branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinNode.java 2006-03-17 22:08:11 UTC (rev 9654) +++ branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinNode.java 2006-03-19 03:13:00 UTC (rev 9655) @@ -0,0 +1,54 @@ +package org.hibernate.hql.ast.tree; + +import antlr.Token; + +/** + * Represents an HQL join. The coneptualization here is strictly that of + * the join in terms of the context of the HQL query which may or may not have + * direct correlation to any SQL join. + * + * @author Steve Ebersole + */ +public class JoinNode extends Node { + + private JoinType joinType; + private JoinSource source; + private boolean fetch; + + public JoinNode() { + } + + public JoinNode(Token tok) { + super( tok ); + } + + public JoinNode(JoinType joinType, JoinSource source, boolean fetch) { + this.joinType = joinType; + this.source = source; + this.fetch = fetch; + } + + public JoinType getJoinType() { + return joinType; + } + + public void setJoinType(JoinType joinType) { + this.joinType = joinType; + } + + public JoinSource getSource() { + return source; + } + + public void setSource(JoinSource source) { + this.source = source; + } + + public boolean isFetch() { + return fetch; + } + + public void setFetch(boolean fetch) { + this.fetch = fetch; + } +} Added: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinSource.java =================================================================== --- branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinSource.java 2006-03-17 22:08:11 UTC (rev 9654) +++ branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinSource.java 2006-03-19 03:13:00 UTC (rev 9655) @@ -0,0 +1,50 @@ +package org.hibernate.hql.ast.tree; + +import java.util.HashMap; +import java.io.Serializable; + +/** + * Represents the source of a join, in the context of the HQL query. + */ +public class JoinSource implements Serializable { + + /** + * Indicates a join using the HQL explicit join syntax (i.e. the join keyword). + */ + public static final JoinSource EXPLICIT = new JoinSource( "explicit" ); + /** + * Indicates a join defined by implicit syntax (i.e. a path expression). + */ + public static final JoinSource IMPLICIT = new JoinSource( "implicit" ); + /** + * Indicates a join that is the result of an indexed operation (i.e. []) + * on an indexed or keyed collection (list or map). + */ + public static final JoinSource INDEXED = new JoinSource( "indexed" ); + /** + * Indicates a theta-style join (i.e. from A a, B b where a.id = b.id...) + */ + public static final JoinSource THETA = new JoinSource( "theta" ); + + private static final HashMap INSTANCES = new HashMap(); + static { + INSTANCES.put( EXPLICIT.name, EXPLICIT ); + INSTANCES.put( IMPLICIT.name, IMPLICIT ); + INSTANCES.put( INDEXED.name, INDEXED ); + INSTANCES.put( THETA.name, THETA ); + } + + private final String name; + + private JoinSource(String name) { + this.name = name; + } + + public String toString() { + return name; + } + + private Object readResolve() { + return INSTANCES.get( name ); + } +} Added: branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinType.java =================================================================== --- branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinType.java 2006-03-17 22:08:11 UTC (rev 9654) +++ branches/HQL_ANTLR_2/Hibernate3/src/org/hibernate/hql/ast/tree/JoinType.java 2006-03-19 03:13:00 UTC (rev 9655) @@ -0,0 +1,60 @@ +package org.hibernate.hql.ast.tree; + +import java.io.Serializable; +import java.util.HashMap; + +/** + * Represents a canonical join type. + * <p/> + * Note that currently HQL really only supports inner and left outer joins + * (though cross joins can also be achieved). This is because joins in HQL + * are always defined in relation to a mapped association. However, when we + * start allowing users to specify ad-hoc joins this may need to change to + * allow the full spectrum of join types. Thus the others are provided here + * currently just for completeness and for future expansion. + */ +public class JoinType implements Serializable { + /** + * Represents an inner join. + */ + public static final JoinType INNER = new JoinType( "inner" ); + /** + * Represents a left outer join. + */ + public static final JoinType LEFT = new JoinType( "left outer" ); + /** + * Represents a right outer join. + */ + public static final JoinType RIGHT = new JoinType( "right outer" ); + /** + * Represents a cross join (aka a cartesian product). + */ + public static final JoinType CROSS = new JoinType( "cross" ); + /** + * Represents a full join. + */ + public static final JoinType FULL = new JoinType( "full" ); + + private static final HashMap INSTANCES = new HashMap(); + static { + INSTANCES.put( INNER.name, INNER ); + INSTANCES.put( LEFT.name, LEFT ); + INSTANCES.put( RIGHT.name, RIGHT ); + INSTANCES.put( CROSS.name, CROSS ); + INSTANCES.put( FULL.name, FULL ); + } + + private final String name; + + private JoinType(String name) { + this.name = name; + } + + public String toString() { + return name; + } + + private Object readResolve() { + return INSTANCES.get( name ); + } +} |
From: <hib...@li...> - 2006-03-17 22:08:18
|
Author: ste...@jb... Date: 2006-03-17 17:08:11 -0500 (Fri, 17 Mar 2006) New Revision: 9654 Added: branches/HQL_ANTLR_2/Hibernate3/ Log: branching for ANTLR redesign work Copied: branches/HQL_ANTLR_2/Hibernate3 (from rev 9653, trunk/Hibernate3) |
From: <hib...@li...> - 2006-03-17 22:06:13
|
Author: ste...@jb... Date: 2006-03-17 17:06:08 -0500 (Fri, 17 Mar 2006) New Revision: 9653 Added: branches/HQL_ANTLR_2/ Log: branch directory for redesign work for the ANTLR parser |
From: <hib...@li...> - 2006-03-17 18:59:11
|
Author: ste...@jb... Date: 2006-03-17 13:59:03 -0500 (Fri, 17 Mar 2006) New Revision: 9652 Modified: trunk/Hibernate3/src/org/hibernate/classic/Session.java Log: HHH-590 Modified: trunk/Hibernate3/src/org/hibernate/classic/Session.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/classic/Session.java 2006-03-17 14:50:16 UTC (rev 9651) +++ trunk/Hibernate3/src/org/hibernate/classic/Session.java 2006-03-17 18:59:03 UTC (rev 9652) @@ -26,8 +26,9 @@ * given instance is unsaved or does not exist in the database, save it and * return it as a newly persistent instance. Otherwise, the given instance * does not become associated with the session. - * @deprecated use org.hibernate.Session#merge(Object) * + * @deprecated use {@link org.hibernate.Session#merge(Object)} + * * @param object a transient instance with state to be copied * @return an updated persistent instance */ @@ -40,8 +41,9 @@ * there is no database row with the given identifier, save the given instance * and return it as a newly persistent instance. Otherwise, the given instance * does not become associated with the session. - * @deprecated use org.hibernate.Session#merge(Object, java.io.Serializable) * + * @deprecated with no replacement + * * @param object a persistent or transient instance with state to be copied * @param id the identifier of the instance to copy to * @return an updated persistent instance @@ -55,8 +57,9 @@ * given instance is unsaved or does not exist in the database, save it and * return it as a newly persistent instance. Otherwise, the given instance * does not become associated with the session. - * @deprecated use org.hibernate.Session#merge(String, Object) * + * @deprecated use {@link org.hibernate.Session#merge(String, Object)} + * * @param object a transient instance with state to be copied * @return an updated persistent instance */ @@ -69,8 +72,9 @@ * there is no database row with the given identifier, save the given instance * and return it as a newly persistent instance. Otherwise, the given instance * does not become associated with the session. - * @deprecated use org.hibernate.Session#merge(String, Object, java.io.Serializable) * + * @deprecated with no replacement + * * @param object a persistent or transient instance with state to be copied * @param id the identifier of the instance to copy to * @return an updated persistent instance @@ -79,8 +83,9 @@ /** * Execute a query. - * @deprecated use <tt>createQuery(query).list()</tt> * + * @deprecated use {@link #createQuery}.{@link Query#list()} + * * @param query a query expressed in Hibernate's query language * @return a distinct list of instances (or arrays of instances) * @throws HibernateException @@ -88,10 +93,10 @@ public List find(String query) throws HibernateException; /** - * Execute a query with bind parameters. - * @deprecated use <tt>createQuery(query).setParameter(value,type).list()</tt> + * Execute a query with bind parameters, binding a value to a "?" parameter + * in the query string. * - * Bind a value to a "?" parameter in the query string. + * @deprecated use {@link #createQuery}.setXYZ.{@link Query#list()} * * @param query the query string * @param value a value to be bound to a "?" placeholder (JDBC IN parameter). @@ -103,10 +108,10 @@ public List find(String query, Object value, Type type) throws HibernateException; /** - * Execute a query with bind parameters. - * @deprecated use <tt>createQuery(query).setParameters(values,types).find() instead</tt> + * Execute a query with bind parameters, binding an array of values to "?" + * parameters in the query string. * - * Binding an array of values to "?" parameters in the query string. + * @deprecated use {@link #createQuery}.setXYZ.{@link Query#list()} * * @param query the query string * @param values an array of values to be bound to the "?" placeholders (JDBC IN parameters). @@ -125,7 +130,7 @@ * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve * objects than <tt>find()</tt>. * - * @deprecated use <tt>createQuery(query).iterate()</tt> + * @deprecated use {@link #createQuery}.{@link Query#iterate} * * @param query the query string * @return an iterator @@ -141,9 +146,9 @@ * Entities returned as results are initialized on demand. The first SQL query returns * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve * objects than <tt>find()</tt>. - * - * @deprecated use <tt>createQuery(query).setParameter(value,type).iterate()</tt> * + * @deprecated use {@link #createQuery}.setXYZ.{@link Query#iterate} + * * @param query the query string * @param value a value to be witten to a "?" placeholder in the query string * @param type the hibernate type of value @@ -160,9 +165,9 @@ * Entities returned as results are initialized on demand. The first SQL query returns * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve * objects than <tt>find()</tt>. - * - * @deprecated use <tt>createQuery(query).setParameters(values,types).iterate()</tt> * + * @deprecated use {@link #createQuery}.setXYZ.{@link Query#iterate} + * * @param query the query string * @param values a list of values to be written to "?" placeholders in the query * @param types a list of Hibernate types of the values @@ -176,7 +181,7 @@ * <tt>this</tt>, the collection element. Filters allow efficient access to very large lazy * collections. (Executing the filter does not initialize the collection.) * - * @deprecated use <tt>createQuery()</tt> + * @deprecated use {@link #createFilter(Object, String)}.{@link Query#list} * * @param collection a persistent collection to filter * @param filter a filter query string @@ -188,9 +193,9 @@ /** * Apply a filter to a persistent collection. A filter is a Hibernate query that may refer to * <tt>this</tt>, the collection element. - * - * @deprecated use <tt>createQuery()</tt> * + * @deprecated use {@link #createFilter(Object, String)}.setXYZ.{@link Query#list} + * * @param collection a persistent collection to filter * @param filter a filter query string * @param value a value to be witten to a "?" placeholder in the query string @@ -205,9 +210,9 @@ * * Bind the given parameters to "?" placeholders. A filter is a Hibernate query that * may refer to <tt>this</tt>, the collection element. - * - * @deprecated use <tt>createQuery()</tt> * + * @deprecated use {@link #createFilter(Object, String)}.setXYZ.{@link Query#list} + * * @param collection a persistent collection to filter * @param filter a filter query string * @param values a list of values to be written to "?" placeholders in the query @@ -219,8 +224,12 @@ /** * Delete all objects returned by the query. Return the number of objects deleted. + * <p/> + * Note that this is very different from the delete-statement support added in HQL + * since 3.1. The functionality here is to actually peform the query and then iterate + * the results calling {@link #delete(Object)} individually. * - * @deprecated use <tt>createQuery()</tt> + * @deprecated consider using HQL delete statements * * @param query the query string * @return the number of instances deleted @@ -230,9 +239,13 @@ /** * Delete all objects returned by the query. Return the number of objects deleted. - * - * @deprecated use <tt>createQuery()</tt> + * <p/> + * Note that this is very different from the delete-statement support added in HQL + * since 3.1. The functionality here is to actually peform the query and then iterate + * the results calling {@link #delete(Object)} individually. * + * @deprecated consider using HQL delete statements + * * @param query the query string * @param value a value to be witten to a "?" placeholder in the query string. * @param type the hibernate type of value. @@ -243,9 +256,13 @@ /** * Delete all objects returned by the query. Return the number of objects deleted. - * - * @deprecated use <tt>createQuery()</tt> + * <p/> + * Note that this is very different from the delete-statement support added in HQL + * since 3.1. The functionality here is to actually peform the query and then iterate + * the results calling {@link #delete(Object)} individually. * + * @deprecated consider using HQL delete statements + * * @param query the query string * @param values a list of values to be written to "?" placeholders in the query. * @param types a list of Hibernate types of the values @@ -257,6 +274,7 @@ /** * Create a new instance of <tt>Query</tt> for the given SQL string. + * * @deprecated will be replaced with a more Query like interface in later release * * @param sql a query expressed in SQL @@ -267,6 +285,7 @@ /** * Create a new instance of <tt>Query</tt> for the given SQL string. + * * @deprecated will be replaced with a more Query like interface in later release * * @param sql a query expressed in SQL @@ -280,6 +299,7 @@ * Persist the given transient instance, using the given identifier. This operation * cascades to associated instances if the association is mapped with * <tt>cascade="save-update"</tt>. + * * @deprecated declare identifier properties for all classes * * @param object a transient instance of a persistent class @@ -292,6 +312,7 @@ * Persist the given transient instance, using the given identifier. This operation * cascades to associated instances if the association is mapped with * <tt>cascade="save-update"</tt>. + * * @deprecated declare identifier properties for all classes * * @param object a transient instance of a persistent class @@ -305,6 +326,7 @@ * is thrown if there is a persistent instance with the same identifier in the * current session. This operation cascades to associated instances * if the association is mapped with <tt>cascade="save-update"</tt>. + * * @deprecated declare identifier properties for all classes * * @param object a detached instance containing updated state @@ -318,6 +340,7 @@ * is thrown if there is a persistent instance with the same identifier in the * current session. This operation cascades to associated instances * if the association is mapped with <tt>cascade="save-update"</tt>. + * * @deprecated declare identifier properties for all classes * * @param object a detached instance containing updated state |
From: <hib...@li...> - 2006-03-17 14:50:34
|
Author: max...@jb... Date: 2006-03-17 09:50:16 -0500 (Fri, 17 Mar 2006) New Revision: 9651 Modified: trunk/Hibernate3/src/org/hibernate/property/ChainedPropertyAccessor.java Log: correct property not fond exception Modified: trunk/Hibernate3/src/org/hibernate/property/ChainedPropertyAccessor.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/property/ChainedPropertyAccessor.java 2006-03-17 14:50:00 UTC (rev 9650) +++ trunk/Hibernate3/src/org/hibernate/property/ChainedPropertyAccessor.java 2006-03-17 14:50:16 UTC (rev 9651) @@ -1,10 +1,5 @@ -/* - * Created on 28-Jan-2005 - * - */ package org.hibernate.property; -import org.hibernate.PropertyAccessException; import org.hibernate.PropertyNotFoundException; /** @@ -31,7 +26,7 @@ // ignore } } - throw new PropertyNotFoundException("Could not find Getter "); + throw new PropertyNotFoundException("Could not find getter for " + propertyName + " on " + theClass); } public Setter getSetter(Class theClass, String propertyName) @@ -46,7 +41,7 @@ // } } - throw new PropertyAccessException(null, "could not find a property " , false, theClass, propertyName); + throw new PropertyNotFoundException("Could not find setter for " + propertyName + " on " + theClass); } } |
From: <hib...@li...> - 2006-03-17 14:50:21
|
Author: max...@jb... Date: 2006-03-17 09:50:00 -0500 (Fri, 17 Mar 2006) New Revision: 9650 Modified: branches/Branch_3_1/Hibernate3/src/org/hibernate/property/ChainedPropertyAccessor.java Log: correct property not fond exception Modified: branches/Branch_3_1/Hibernate3/src/org/hibernate/property/ChainedPropertyAccessor.java =================================================================== --- branches/Branch_3_1/Hibernate3/src/org/hibernate/property/ChainedPropertyAccessor.java 2006-03-17 11:25:05 UTC (rev 9649) +++ branches/Branch_3_1/Hibernate3/src/org/hibernate/property/ChainedPropertyAccessor.java 2006-03-17 14:50:00 UTC (rev 9650) @@ -1,10 +1,5 @@ -/* - * Created on 28-Jan-2005 - * - */ package org.hibernate.property; -import org.hibernate.PropertyAccessException; import org.hibernate.PropertyNotFoundException; /** @@ -31,7 +26,7 @@ // ignore } } - throw new PropertyNotFoundException("Could not find Getter "); + throw new PropertyNotFoundException("Could not find getter for " + propertyName + " on " + theClass); } public Setter getSetter(Class theClass, String propertyName) @@ -46,7 +41,7 @@ // } } - throw new PropertyAccessException(null, "could not find a property " , false, theClass, propertyName); + throw new PropertyNotFoundException("Could not find setter for " + propertyName + " on " + theClass); } } |
From: <hib...@li...> - 2006-03-17 11:25:14
|
Author: max...@jb... Date: 2006-03-17 06:25:05 -0500 (Fri, 17 Mar 2006) New Revision: 9649 Modified: trunk/Hibernate3/src/org/hibernate/transform/AliasToEntityMapResultTransformer.java Log: more efficent aliastoentitymap transformation Modified: trunk/Hibernate3/src/org/hibernate/transform/AliasToEntityMapResultTransformer.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/transform/AliasToEntityMapResultTransformer.java 2006-03-17 11:25:00 UTC (rev 9648) +++ trunk/Hibernate3/src/org/hibernate/transform/AliasToEntityMapResultTransformer.java 2006-03-17 11:25:05 UTC (rev 9649) @@ -11,7 +11,7 @@ public class AliasToEntityMapResultTransformer implements ResultTransformer { public Object transformTuple(Object[] tuple, String[] aliases) { - Map result = new HashMap(); + Map result = new HashMap(tuple.length); for ( int i=0; i<tuple.length; i++ ) { String alias = aliases[i]; if ( alias!=null ) { |
From: <hib...@li...> - 2006-03-17 11:25:07
|
Author: max...@jb... Date: 2006-03-17 06:25:00 -0500 (Fri, 17 Mar 2006) New Revision: 9648 Modified: branches/Branch_3_1/Hibernate3/src/org/hibernate/transform/AliasToEntityMapResultTransformer.java Log: more efficent aliastoentitymap transformation Modified: branches/Branch_3_1/Hibernate3/src/org/hibernate/transform/AliasToEntityMapResultTransformer.java =================================================================== --- branches/Branch_3_1/Hibernate3/src/org/hibernate/transform/AliasToEntityMapResultTransformer.java 2006-03-17 11:09:10 UTC (rev 9647) +++ branches/Branch_3_1/Hibernate3/src/org/hibernate/transform/AliasToEntityMapResultTransformer.java 2006-03-17 11:25:00 UTC (rev 9648) @@ -11,7 +11,7 @@ public class AliasToEntityMapResultTransformer implements ResultTransformer { public Object transformTuple(Object[] tuple, String[] aliases) { - Map result = new HashMap(); + Map result = new HashMap(tuple.length); for ( int i=0; i<tuple.length; i++ ) { String alias = aliases[i]; if ( alias!=null ) { |
From: <hib...@li...> - 2006-03-17 11:09:28
|
Author: epbernard Date: 2006-03-17 06:09:10 -0500 (Fri, 17 Mar 2006) New Revision: 9647 Modified: trunk/HibernateExt/ejb/build.properties.dist trunk/HibernateExt/ejb/changelog.txt trunk/HibernateExt/ejb/doc/reference/en/master.xml trunk/HibernateExt/ejb/doc/reference/en/modules/configuration.xml trunk/HibernateExt/ejb/lib/README.txt trunk/HibernateExt/ejb/lib/hibernate-annotations.jar trunk/HibernateExt/ejb/readme.txt Log: Release Doc fixes(EJB-96 EJB-80) include annotations jar Modified: trunk/HibernateExt/ejb/build.properties.dist =================================================================== --- trunk/HibernateExt/ejb/build.properties.dist 2006-03-17 11:00:54 UTC (rev 9646) +++ trunk/HibernateExt/ejb/build.properties.dist 2006-03-17 11:09:10 UTC (rev 9647) @@ -3,4 +3,4 @@ test.dir=test resources.dir=resources testresources.dir=test-resources -hibernate-core.home=../hibernate-3.1 \ No newline at end of file +hibernate-core.home=../hibernate-3.2 \ No newline at end of file Modified: trunk/HibernateExt/ejb/changelog.txt =================================================================== --- trunk/HibernateExt/ejb/changelog.txt 2006-03-17 11:00:54 UTC (rev 9646) +++ trunk/HibernateExt/ejb/changelog.txt 2006-03-17 11:09:10 UTC (rev 9647) @@ -1,6 +1,41 @@ Hibernate EntityManager Changelog ================================== +3.1beta7 (17-03-2006) +--------------------- + +** Bug + * [EJB-80] - EMF bootstrapping doesn't work as documented + * [EJB-96] - Spelling error in 2.4 section of reference doc + * [EJB-114] - NPE when Persistence.createEntityManager(String) is used + * [EJB-115] - wrong loglevel in PersistenceXmlLoader.java (line 101) + * [EJB-118] - PersistenceXmlLoader logging a fail message + * [EJB-119] - @EntityResult definition is not correct + * [EJB-123] - Exception "EntityManager is closed" throwed when trying to check isOpen() + * [EJB-125] - Can't use Hibernate's FlushMode.NEVER with an EntityManager + * [EJB-139] - em.getTransaction() should raise IllegalStateException if accessed on a JTA EM + * [EJB-145] - Support EntityManager.joinTransaction() + + +** Improvement + * [EJB-77] - Getting access to the annotationconfiguration behind a Ejb3Configuration + * [EJB-135] - em.close() should close the API but let the EM in sync with the attached transaction + * [EJB-147] - Validate persistence.xml file from persistence_1_0.xsd + +** New Feature + * [EJB-90] - Mark transaction for Rollbacked on PersistenceException + * [EJB-106] - EntityManager.lock( , LockModeType.WRITE) + * [EJB-138] - Implements EntityTransaction.setRollbackOnly() + * [EJB-141] - Update EntityManagerFactory interface by removing PersistenceContextType and adding the overriding map + * [EJB-142] - RollbackTransaction on JTA should clear the persistence context + * [EJB-143] - Set the transaction_factory automatically from Transaction_type unless explicitly set + * [EJB-144] - Failure of EntityTransaction.commit() should rollback(); + + +** Task + * [EJB-107] - Check use of persistenceUnitInfo.getClassLoader() + + 3.1beta6 (20-01-2006) --------------------- ** Bug Modified: trunk/HibernateExt/ejb/doc/reference/en/master.xml =================================================================== --- trunk/HibernateExt/ejb/doc/reference/en/master.xml 2006-03-17 11:00:54 UTC (rev 9646) +++ trunk/HibernateExt/ejb/doc/reference/en/master.xml 2006-03-17 11:09:10 UTC (rev 9647) @@ -61,112 +61,4 @@ &native; - <appendix> - <title id="compliance">Compliance and known limitations</title> - - <synopsis>3.1beta6 (20-01-2006) ---------------------- -** Bug - * [EJB-93] - @PrePersist callback not called on cascade - * [EJB-110] - misnamed method in PersistenceUnitInfo - * [EJB-111] - close() throws IllegalStateException( "transaction in progress") - -** New Feature - * [EJB-50] - Entity callbacks should handle subclassing - * [EJB-83] - PersistentUnitInfo and new persistence.xml schema as per the pfd - * [EJB-85] - Support CUD operations out of transactions - * [EJB-86] - EntityManager.getFlushMode() - * [EJB-87] - EntityManager.lock( , LockModeType.READ) - * [EJB-88] - EntityManager.clear() - * [EJB-89] - Replace EntityNotFoundException to NoResultException for query.getSingleResult() - * [EJB-91] - persistence.xml structure changes as per the PFD - * [EJB-92] - Implements transactional-type - * [EJB-104] - Flag for class file transformation - * [EJB-108] - Support EJB3 overriding properties (provider, jta / non-jta datasource, transactionType) over persistence.xml - - -** Improvement - * [EJB-100] - Multiple lifecycle per event - * [EJB-102] - EJB3 no longer requires to rollback the ids - - -** Deprecation - * [EJB-105] - Implicit positional parameters for EJBQL queries is no longer supported - -3.1beta5 (13-12-2005) ---------------------- - -** Bug - * [EJB-52] - PERSIST cascade loads unilitialized elements at flush time - * [EJB-68] - hibernate.ejb.interceptor property in persistence.xml is ignored - * [EJB-73] - Id is not set in @PostPersist - * [EJB-76] - JarVisitor unqualify algorithm fails when the name ends with 'ar' and is less than 4 chars - * [EJB-78] - default value for hibernate.transaction.flush_before_completion - -** New Feature - * [EJB-58] - Support @MyAnnotation annotated with an @EntityListener - * [EJB-71] - Support custom event listeners - - -** Improvement - * [EJB-35] - Support custom NamingStrategy as property. - * [EJB-72] - Make setDataSource() more out of container friendly - * [EJB-75] - Fall back to <property name="blah">blah</property> when the value attribute is empty - * [EJB-79] - Package.getPackage() returns null on some classloaders - - -3.1beta4 (06-10-2005) ---------------------- - * EJB-67 Lazy access to the stream in JarVisitor leading to a non access when filters are empty (ie no filters) - * EJB-65 handle eclipse bundleresource url protocol during metadata search - * EJB-66 Support all url protocols that returns zip streams for jars like http - * EJB-62 Error during stateful session bean passivation - * EJB-61 implicit parameter ? no longer supported - * EJB-63 Positional parameters should start from index 1 to say sort of consistent with the spec - -3.1beta3 (14-09-2005) ---------------------- - * EJB-6 Support ?1, ?2 style positional parameters - * EJB-60 Support byte code instrumentation via a ClassFileTransformer - * EJB-55 Problems using a .par file with Tomcat - * EJB-56 Support exploded jar files *not* ending with .xar - * EJB-51 Support persistence.xml declaration and hibernate.cfg.xml - * EJB-53 DELETE_ORPHAN not executed at flush time - * EJB-52 Persist cascade loads uninitialized elements at flush time - * EJB-43 Autodetection magic leads to duplicate imports - * EJB-24 ByteArrayBlobType incompatible with Oracle - * EJB-28 create an EMF through PersistenceInfo - * EJB-44 Support Hibernate Interceptors in EJB3 imlementation as an extension - * EJB-40 Entity callbacks should cast away access modifiers - * EJB-48 Plug Validator framework into HEM - * EJB-47 Validator and Jacc event listeners clashes - -3.1beta2 (04-08-2005) ---------------------- - * Support package names in <class /> - * EJB-42 Autodetection magic ignores hibernate.cfg.xml - * EJB-45 Allow to disable autodetection in .par through a property - * EJB-41 Short-circuit dirty checking when no callback are actually called - * EJB-38 Standalone EM should search for package-info files - * EJB-31 Out-of-container should search for .hbm.xml files - * EJB-29 Lifecycle callbacks and dirty checking clash - * EJB-36 proxied instances raise an exception in em.contains() - * EJB-28 support injected DataSource - * EJB-34 EMF.isOpen() is wrong - * EJB-27 Support transaction-less operations with getEntityManager() - * EJB-23 No lifecycle interceptor used when getCurrentSession() is called - * EJB-20 Sync Hibernate *state* and entity on lifecycle @Callbacks - * EJB-21 NPE in TransactionImpl.isActive() when tx is not initialized (Shane Bryzak) - * EJB-19 <jar-file /> analysed, but the resource path is mandatory and not only the jar name - * EJB-18 get mapped classes from .par files both exploded and regular zip - -3.1beta1 Preview (24-06-2005) ------------------------------ -Initial release - -Missing features for spec compliance -==================================== -* XML deployment descriptor -* Support scalar results in native queries</synopsis> - </appendix> </book> \ No newline at end of file Modified: trunk/HibernateExt/ejb/doc/reference/en/modules/configuration.xml =================================================================== --- trunk/HibernateExt/ejb/doc/reference/en/modules/configuration.xml 2006-03-17 11:00:54 UTC (rev 9646) +++ trunk/HibernateExt/ejb/doc/reference/en/modules/configuration.xml 2006-03-17 11:09:10 UTC (rev 9647) @@ -243,10 +243,16 @@ called, the persistence implementation will search your classpath for any <code>META-INF/persistence.xml</code> files using the <code>ClassLoader.getResource("META-INF/persistence.xml")</code> method. - From this list of resources, it will try to find an entity manager that - matches the name you specify in the command line with what is specified - in the persistence.xml file. If no persistence.xml with the correct name - are found, a <classname>PersistenceException</classname> is + Actually the <classname>Persistence</classname> class will look at all + the Persistence Providers available in the classpath and ask each of + them if they are responsible for the creation of the entity manager + factory <literal>manager1</literal>. Each provider, from this list of + resources, it will try to find an entity manager that matches the name + you specify in the command line with what is specified in the + persistence.xml file (of course the provider <literal>element</literal> + must match the current persistent provider). If no persistence.xml with + the correct name are found or if the expected persistence provider is + not found, a <classname>PersistenceException</classname> is raised.</para> <para>Apart from Hibernate system-level settings, all the properties @@ -573,7 +579,7 @@ entity manager factory.</para> <programlisting>// Use persistence.xml configuration -EntityManagerFactory emf = Peristence.createEntityManagerFactory("manager1") +EntityManagerFactory emf = Persistence.createEntityManagerFactory("manager1") EntityManager em = emf.createEntityManager(); // Retrieve an application managed entity manager // Work with the EM em.close(); Modified: trunk/HibernateExt/ejb/lib/README.txt =================================================================== --- trunk/HibernateExt/ejb/lib/README.txt 2006-03-17 11:00:54 UTC (rev 9646) +++ trunk/HibernateExt/ejb/lib/README.txt 2006-03-17 11:09:10 UTC (rev 9647) @@ -1,7 +1,7 @@ Hibernate Metadata dependencies =============================== -ejb3-persistence (public draft version): required -hibernate-annotations (3.1beta4): required +ejb3-persistence (proposed final draft): required +hibernate-annotations (3.1beta9): required javassist (3.0): required jboss-archive-browsing (5.0.0alpha build: CVSTag=HEAD date=200507071617): required Modified: trunk/HibernateExt/ejb/lib/hibernate-annotations.jar =================================================================== (Binary files differ) Modified: trunk/HibernateExt/ejb/readme.txt =================================================================== --- trunk/HibernateExt/ejb/readme.txt 2006-03-17 11:00:54 UTC (rev 9646) +++ trunk/HibernateExt/ejb/readme.txt 2006-03-17 11:09:10 UTC (rev 9647) @@ -1,9 +1,9 @@ Hibernate EntityManager ================================================== -Version: 3.1 beta 6, 20.01.2006 +Version: 3.1 beta 7, 17.03.2006 -THIS RELEASE OF HIBERNATE ENTITYMANAGER REQUIRES HIBERNATE 3.1.1 AND DOES -NOT WORK WITH HIBERNATE 3.0.x OR ANY OLDER VERSION OF HIBERNATE. +THIS RELEASE OF HIBERNATE ENTITYMANAGER REQUIRES HIBERNATE 3.2alpha2 AND DOES +NOT WORK WITH HIBERNATE 3.1.x OR ANY OLDER VERSION OF HIBERNATE. Description |
From: <hib...@li...> - 2006-03-17 11:01:16
|
Author: epbernard Date: 2006-03-17 06:00:54 -0500 (Fri, 17 Mar 2006) New Revision: 9646 Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java Log: EJB-77 Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java =================================================================== --- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java 2006-03-17 09:58:25 UTC (rev 9645) +++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java 2006-03-17 11:00:54 UTC (rev 9646) @@ -906,4 +906,15 @@ public void setListeners(String type, Object[] listeners) { cfg.setListeners( type, listeners ); } + + /** + * This API is intended to give a read-only configuration. + * It is sueful when working with SchemaExport or any Configuration based + * tool. + * DO NOT update configuration through it. + */ + public AnnotationConfiguration getHibernateConfiguration() { + //TODO make it really read only (maybe through proxying) + return cfg; + } } |
From: <hib...@li...> - 2006-03-17 09:58:30
|
Author: epbernard Date: 2006-03-17 04:58:25 -0500 (Fri, 17 Mar 2006) New Revision: 9645 Modified: trunk/HibernateExt/metadata/changelog.txt trunk/HibernateExt/metadata/readme.txt Log: release Modified: trunk/HibernateExt/metadata/changelog.txt =================================================================== --- trunk/HibernateExt/metadata/changelog.txt 2006-03-17 09:34:28 UTC (rev 9644) +++ trunk/HibernateExt/metadata/changelog.txt 2006-03-17 09:58:25 UTC (rev 9645) @@ -1,6 +1,57 @@ Hibernate Annotations Changelog =============================== +3.1beta9 Preview (17-03-2006) +----------------------------- +** Bug + * [ANN-16] - Annotations: composite pk with two manytoone not working + * [ANN-98] - Wrong unsaved-value strategy for IdClass entities + * [ANN-196] - sequence should increase by assocationSize rather than regular hilo + * [ANN-197] - table generator should stock hi * low_max instead of hi + * [ANN-211] - ClassValidator throws NPE during flush + * [ANN-230] - Id Annotation - bad example of GeneratedValue + * [ANN-234] - @NotNull syntax doesn't make join column null in conjunction with @OneToOne or @ManyToOne + * [ANN-236] - @OneToMany(mappedBy) cannot referenced an hbm file described entity + * [ANN-240] - @AttributeOverride only works in @Entity, not @MappedSuperclass + * [ANN-241] - @Index broken on property when no columnName is defined + * [ANN-253] - Do not raise unresolved type exception if targetEntity is defined on the association annotation + * [ANN-254] - References to invalid CascadeType.CREATE in documentation + * [ANN-255] - Validator problem with @Valid @Embedded objects + * [ANN-256] - Incorrect classloader used for ResourceBundle loading in JavaEE environment + * [ANN-257] - referencedColumnName is not recognized on a many-to-one to a composite primary key + * [ANN-258] - OneToOne annotation: Hibernate is not respecting the optional=true behaviour + * [ANN-266] - @Temporal on Calendar is not mapped properly + * [ANN-269] - doc error in example validation annotation + * [ANN-274] - @AttributeOverride ignored when defined on an @Entity having a @MappedSuperclass annotated with @IdClass + * [ANN-280] - Index not work + * [ANN-282] - @IdClass including @Id claims no identifier property rather than @Id not authorized + + +** Improvement + * [ANN-146] - @NotNull should be ignored for SINGLE_TABLE subclass properties + * [ANN-208] - Enable @Valid for Collections, Maps and Arrays + * [ANN-223] - Entity name should be the default for discriminator value (not the fqcn) + * [ANN-233] - @Email not documented + * [ANN-245] - Better doc on MapKey explaining that the column is shared between the key and the referenced property + * [ANN-262] - @org.hibernate.annotatios.Table.name remaned in @...Table.appliesTo + * [ANN-271] - Change @EntityResult(Class entityClass) ( was @EntityResult(String name) ) + * [ANN-272] - Remove TYPE @Target on @JoinColumn(s) + * [ANN-275] - Default discriminator column is DTYPE rather than TYPE + +** New Feature + * [ANN-15] - Use of @ManyToOne in a @EmbeddedId + * [ANN-226] - Allow Associations within an @Embeddable Class + * [ANN-259] - @OnDelete for @OneToOne and @ManyToOne (Radim Tlusty, Mat?j Kraus) + * [ANN-270] - Add @SqlResultSetMappings + * [ANN-273] - @AssociationOverride(s) similar to @AttributeOverride(s) + * [ANN-287] - Abstraction layer on top of reflection calls (Paolo Perrotta, Davide Marchignoli) + + +** Task + * [ANN-228] - Get rid of the compliance and limitation section in the doc. + * [ANN-239] - DefaultValidatorMessages_de.properties: translation errors + + 3.1beta8 Preview (20-01-2006) ----------------------------- ** Bug Modified: trunk/HibernateExt/metadata/readme.txt =================================================================== --- trunk/HibernateExt/metadata/readme.txt 2006-03-17 09:34:28 UTC (rev 9644) +++ trunk/HibernateExt/metadata/readme.txt 2006-03-17 09:58:25 UTC (rev 9645) @@ -1,9 +1,9 @@ Hibernate Annotations ================================================== -Version: 3.1 beta 8, 20.01.2006 +Version: 3.1 beta 9, 17.03.2006 -THIS RELEASE OF HIBERNATE ANNOTATIONS REQUIRES HIBERNATE 3.1.1 AND DOES NOT WORK -WITH HIBERNATE 3.0.x OR ANY OLDER VERSION OF HIBERNATE. +THIS RELEASE OF HIBERNATE ANNOTATIONS REQUIRES HIBERNATE 3.2alpha2 AND DOES NOT WORK +WITH HIBERNATE 3.1.x OR ANY OLDER VERSION OF HIBERNATE. Description |
From: <hib...@li...> - 2006-03-17 09:34:31
|
Author: epbernard Date: 2006-03-17 04:34:28 -0500 (Fri, 17 Mar 2006) New Revision: 9644 Modified: trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml Log: ANN-245 Modified: trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml =================================================================== --- trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml 2006-03-17 08:42:25 UTC (rev 9643) +++ trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml 2006-03-17 09:34:28 UTC (rev 9644) @@ -1125,11 +1125,18 @@ property using <literal>@MapKey(name="myProperty")</literal> (myProperty is a property name in the target entity). When using <literal>@MapKey</literal> (without property name), the target - entity primary key is used. Be aware that once loaded, the key is no - longer kept in sync with the property, in other words, if you change - the property value, the key will not change automatically in your - Java model (Map support the way Hibernate 3 does is currently not - supported in this release).</para> + entity primary key is used. The map key uses the same column as the + property pointed out: there is no additional column defined to hold + the map key, and it does make sense since the map key actually + represent a target ptoperty. Be aware that once loaded, the key is + no longer kept in sync with the property, in other words, if you + change the property value, the key will not change automatically in + your Java model (Map support the way Hibernate 3 does is currently + not supported in this release). Many people confuse + <literal><map></literal> capabilities and + <literal>@MapKey</literal> ones. These are two different features. + <literal>@MapKey</literal> still has some limitations, please check + the forum or the JIRA tracking system for more informations.</para> <para>Hibernate has several notions of collections.</para> @@ -2190,7 +2197,7 @@ or any secondary table. The <literal>@Tables</literal> annotation allows your to apply indexes on different tables. This annotation is expected where <literal>@javax.persistence.Table</literal> or - <literal>@javax.persistence.SecondaryTable</literal>(s) occurs. </para> + <literal>@javax.persistence.SecondaryTable</literal>(s) occurs.</para> <note> <para><literal>@org.hibernate.annotations.Table</literal> is a @@ -2198,7 +2205,7 @@ <literal>@javax.persistence.Table</literal>. Especially, if you want to change the default name of a table, you must use <literal>@javax.persistence.Table</literal>, not - <literal>@org.hibernate.annotations.Table</literal>. </para> + <literal>@org.hibernate.annotations.Table</literal>.</para> </note> <para><programlisting>@Entity |
Author: epbernard Date: 2006-03-17 03:42:25 -0500 (Fri, 17 Mar 2006) New Revision: 9643 Added: trunk/HibernateExt/ejb/src/resources/org/ trunk/HibernateExt/ejb/src/resources/org/hibernate/ trunk/HibernateExt/ejb/src/resources/org/hibernate/ejb/ trunk/HibernateExt/ejb/src/resources/org/hibernate/ejb/persistence_1_0.xsd Modified: trunk/HibernateExt/ejb/ trunk/HibernateExt/ejb/doc/reference/en/master.xml trunk/HibernateExt/ejb/doc/reference/en/modules/architecture.xml trunk/HibernateExt/ejb/doc/reference/en/modules/batch.xml trunk/HibernateExt/ejb/doc/reference/en/modules/configuration.xml trunk/HibernateExt/ejb/doc/reference/en/modules/entitymanagerapi.xml trunk/HibernateExt/ejb/doc/reference/en/modules/transactions.xml trunk/HibernateExt/ejb/lib/ejb3-persistence.jar Log: doc EJB API persistence_1_0.xsd in resource Property changes on: trunk/HibernateExt/ejb ___________________________________________________________________ Name: svn:ignore - build.properties build target test_output + build.properties build target test_output classes Modified: trunk/HibernateExt/ejb/doc/reference/en/master.xml =================================================================== --- trunk/HibernateExt/ejb/doc/reference/en/master.xml 2006-03-16 23:51:58 UTC (rev 9642) +++ trunk/HibernateExt/ejb/doc/reference/en/master.xml 2006-03-17 08:42:25 UTC (rev 9643) @@ -16,7 +16,7 @@ <subtitle>User guide</subtitle> - <releaseinfo>3.1 beta 6</releaseinfo> + <releaseinfo>3.1 beta 7</releaseinfo> <mediaobject> <imageobject> Modified: trunk/HibernateExt/ejb/doc/reference/en/modules/architecture.xml =================================================================== --- trunk/HibernateExt/ejb/doc/reference/en/modules/architecture.xml 2006-03-16 23:51:58 UTC (rev 9642) +++ trunk/HibernateExt/ejb/doc/reference/en/modules/architecture.xml 2006-03-17 08:42:25 UTC (rev 9643) @@ -5,7 +5,7 @@ <section> <title>Definitions</title> - <para>EJB3 is part of the J2EE 5.0 platform. Persistence in EJB3 is + <para>EJB3 is part of the Java EE 5.0 platform. Persistence in EJB3 is available in EJB3 containers, as well as for standalone J2SE applications that execute outside of a particular container. The following programming interfaces and artifacts are available in both environments.</para> @@ -108,13 +108,14 @@ <section> <title>Container-managed entity manager</title> - <para>The most common and widely used entity manager in a J2EE + <para>The most common and widely used entity manager in a Java EE environment is the container-managed entity manager. In this mode, the container is responsible for the opening and closing of the entity manager (this is transparent to the application). It is also responsible for transaction boundaries. A container-managed entity manager is obtained in an application through dependency injection or through JNDI - lookup, A container-managed entity manger requires JTA.</para> + lookup, A container-managed entity manger requires the use of a JTA + transaction.</para> </section> <section> @@ -142,25 +143,18 @@ context available across several transactions.</para> <para>The most common case is to bind the persistence context scope to - the current transaction scope. This is particularly convenient when JTA - transactions are used: the persistence context is associated with the - JTA transaction life cycle. When a entity manager is invoked, the - persistence context is also opened, if there is no persistence context - associated with the current JTA transaction. Otherwise, the associated - persistence context is used. The persistence context ends when the JTA - transaction completes. This means that during the JTA transaction, an - application will be able to work on managed entities of the same - persistence context. In other words, you don't have to pass the entity - manager's persistence context across your EJB method calls, but simply - use dependency injection or lookup whenever you need an entity manager. - For a resource-local entity manager, a new persistence context begins - when a new resource transaction is started (through - <literal>EntityTransaction.begin()</literal>) and ends when the resource - transaction is completed. If the entity manager is invoked outside the - scope of a transaction, the persistence context is created and destroyed - to service only the method call, all entities loaded from the database - will become detached at the end of the method call. This is similar to - auto-commit behavior in traditional JDBC.</para> + the current transaction scope. This is only doable when JTA transactions + are used: the persistence context is associated with the JTA transaction + life cycle. When a entity manager is invoked, the persistence context is + also opened, if there is no persistence context associated with the + current JTA transaction. Otherwise, the associated persistence context + is used. The persistence context ends when the JTA transaction + completes. This means that during the JTA transaction, an application + will be able to work on managed entities of the same persistence + context. In other words, you don't have to pass the entity manager's + persistence context across your EJB method calls, but simply use + dependency injection or lookup whenever you need an entity + manager.</para> <para>You can also use an extended persistence context. This can be combined with stateful session beans, if you use a container-managed @@ -175,13 +169,16 @@ view of the application user, and implement it using an extended persistence context. Please refer to the Hibernate reference manual or the book Hibernate In Action for more information about this pattern. - For an application-managed entity manager the persistence context is - created when the entity manager is created and kept until the entity - manager is closed. In an extended persistence context, all modification - operations (persist, merge, remove) executed outside of a transaction - are queued until the persistence context is executed in a transaction. - The transaction typically occurs at the user process end, allowing the - whole process to be commited or rollbacked.</para> + JBoss Seam is a framework tht link together JSF and EJB3 around the + notion of conversation and unit of work. For an application-managed + entity manager the persistence context is created when the entity + manager is created and kept until the entity manager is closed. In an + extended persistence context, all modification operations (persist, + merge, remove) executed outside a transaction are queued until the + persistence context is attached to a transaction. The transaction + typically occurs at the user process end, allowing the whole process to + be commited or rollbacked. For application-managed entity manager only + support the exctended persistence context.</para> <para>A resource-local entity manager or an entity manager created with <literal>EntityManagerFactory.createEntityManager()</literal> @@ -194,22 +191,15 @@ <title>Persistence context propagation</title> <para>Persistence context propagation occurs for container-managed - entity managers and for entity managers obtained through - <literal>EntityManagerFactory.getEntityManager()</literal>.</para> + entity managers.</para> <para>In a transaction-scoped container managed entity manager (common case in a J2EE environment), the JTA transaction propagation is the same - as the persistence context resource propagation. In other words, all + as the persistence context resource propagation. In other words, container-managed transaction-scoped entity managers retrieved within a given JTA transaction all share the same persistence context. In Hibernate terms, this means all managers share the same session.</para> - <para>When a JTA-bound and application-managed entity manager is - retrieved with <code>EntityManagerFactory.getEntityManager()</code>, the - entity manager returned is associated to the persistence context bound - to the JTA transaction. If no persistence context is associated yet, a - new one is created and associated.</para> - <para>Important: persistence context are never shared between different JTA transactions or between entity manager that do not came from the same entity manager factory. There are some noteworthy exceptions for @@ -259,27 +249,16 @@ <section> <title>J2SE environments</title> - <para>In a J2SE environment only application-managed entity managers are - available. You can retrieve an entity manger using the + <para>In a J2SE environment only extented context application-managed + entity managers are available. You can retrieve an entity manger using the <literal>EntityManagerFactory</literal> API. Only resource-local entity managers are available. In other words, JTA transactions and persistence context propagation are not supported in J2SE (you will have to propagate the persistence context yourself, e.g. using the thread local session pattern popular in the Hibernate community).</para> - <note> - <para>Hibernate3 supports the notion of persistence context propagation - strategy, which will probably be extended to Hibernate Entity Manager, - in the near future.</para> - </note> - - <para>However you can still choose between two different entity manager - strategies. The first one, transaction-scoped entity manager will create a - persistence context each time <literal>EntityTransaction.begin()</literal> - is called. This persistence context will be closed at transaction - completion. The second strategy available is the extended context. In that - case, a persistence context is created when the entity manager is - retrieved (using + <para>Extended context means that a persistence context is created when + the entity manager is retrieved (using <literal>EntityManagerFactory.createEntityManager(EXTENDED)</literal> ) and closed when the entity manager is closed. Many resource-local transaction share the same persistence context, in this case.</para> Modified: trunk/HibernateExt/ejb/doc/reference/en/modules/batch.xml =================================================================== --- trunk/HibernateExt/ejb/doc/reference/en/modules/batch.xml 2006-03-16 23:51:58 UTC (rev 9642) +++ trunk/HibernateExt/ejb/doc/reference/en/modules/batch.xml 2006-03-17 08:42:25 UTC (rev 9643) @@ -57,7 +57,7 @@ .setParameter( "newName", newName ) .setParameter( "oldName", oldName ) .executeUpdate(); -entityManager.getTrasnaction().commit(); +entityManager.getTransaction().commit(); entityManager.close();</programlisting> <para>To execute an EJB-QL <literal>DELETE</literal>, use the same @@ -72,7 +72,7 @@ int deletedEntities = entityManager.createQuery( hqlDelete ) .setParameter( "oldName", oldName ) .executeUpdate(); -entityManager.getTrasnaction().commit(); +entityManager.getTransaction().commit(); entityManager.close();</programlisting> <para>The <literal>int</literal> value returned by the Modified: trunk/HibernateExt/ejb/doc/reference/en/modules/configuration.xml =================================================================== --- trunk/HibernateExt/ejb/doc/reference/en/modules/configuration.xml 2006-03-16 23:51:58 UTC (rev 9642) +++ trunk/HibernateExt/ejb/doc/reference/en/modules/configuration.xml 2006-03-17 08:42:25 UTC (rev 9643) @@ -7,9 +7,9 @@ <para>The EJB3 compatible Hibernate EntityManager is built on top of Hibernate core and Hibernate Annotations. You have to use compatible - versions of each module. This version is known to work on Hibernate 3.1.1 - and Hibernate Annotations 3.1beta8. The following libraries have to be in - your classpath: hibernate3.jar, hibernate-annotations.jar, + versions of each module. This version is known to work on Hibernate + 3.2alpha2 and Hibernate Annotations 3.1beta9. The following libraries have + to be in your classpath: hibernate3.jar, hibernate-annotations.jar, hibernate-entity-manager.jar and all needed third party libraries for each package.(incl. ejb-persistence.jar).</para> </section> @@ -18,19 +18,25 @@ xreflabel="Configuration and bootstrapping"> <title>Configuration and bootstrapping</title> - <para>The configuration for entity managers both inside an application - server and in a standalone application reside in a persistence archive. A - persistence archive is a JAR file which must define a - <literal>persistence.xml</literal> file that resides in the - <filename>META-INF</filename> folder. All properly annotated classes - included in the archive (ie having an <literal>@Entity</literal> - annotation), all annotated packages and all Hibernate hbm.xml files - included in the archive will be added to the persistence unit - configuration, so by default, your persistence.xml will be quite - minimalist:</para> + <section id="setup-configuration-packaging"> + <title>Packaging</title> - <programlisting><persistence> - <persistence-unit> + <para>The configuration for entity managers both inside an application + server and in a standalone application reside in a persistence archive. + A persistence archive is a JAR file which must define a + <literal>persistence.xml</literal> file that resides in the + <filename>META-INF</filename> folder. All properly annotated classes + included in the archive (ie having an <literal>@Entity</literal> + annotation), all annotated packages and all Hibernate hbm.xml files + included in the archive will be added to the persistence unit + configuration, so by default, your persistence.xml will be quite + minimalist:</para> + + <programlisting><persistence xmlns="http://java.sun.com/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" + version="1.0"> + <persistence-unit name="sample"> <jta-data-source>java:/DefaultDS</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/> @@ -39,11 +45,13 @@ </persistence-unit> </persistence></programlisting> - <para>Here's a more complete example of a - <filename><literal>persistence.xml</literal></filename> file</para> + <para>Here's a more complete example of a + <filename><literal>persistence.xml</literal></filename> file</para> - <programlisting> -<persistence> + <programlisting><persistence xmlns="http://java.sun.com/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" + version="1.0"> <persistence-unit name="manager1" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/DefaultDS</jta-data-source> @@ -57,287 +65,319 @@ <property name="hibernate.hbm2ddl.auto" value="create-drop"/> </properties> </persistence-unit> -</persistence> - </programlisting> +</persistence></programlisting> - <variablelist spacing="compact"> - <varlistentry> - <term> - <code>name</code> - </term> + <variablelist spacing="compact"> + <varlistentry> + <term> + <code>name</code> + </term> - <listitem> - <para>(attribute) Every entity manager must have a name. If no name - is specified, the name of the archive file is used minus the - <literal>.jar</literal> suffix.</para> - </listitem> - </varlistentry> + <listitem> + <para>(attribute) Every entity manager must have a name.</para> + </listitem> + </varlistentry> - <varlistentry> - <term> - <code>transaction-type</code> - </term> + <varlistentry> + <term> + <code>transaction-type</code> + </term> - <listitem> - <para>(attribute) Transaction type used. Either JTA or - RESOURCE_LOCAL (default JTA).</para> - </listitem> - </varlistentry> + <listitem> + <para>(attribute) Transaction type used. Either JTA or + RESOURCE_LOCAL (default JTA).</para> + </listitem> + </varlistentry> - <varlistentry> - <term> - <code>provider</code> - </term> + <varlistentry> + <term> + <code>provider</code> + </term> - <listitem> - <para>The provider is a fully-qualified class name of the EJB - Persistence provider. You do not have to define it if you don't work - with several EJB3 implementations. This is needed when you are using - multiple vendor implementations of EJB Persistence.</para> - </listitem> - </varlistentry> + <listitem> + <para>The provider is a fully-qualified class name of the EJB + Persistence provider. You do not have to define it if you don't + work with several EJB3 implementations. This is needed when you + are using multiple vendor implementations of EJB + Persistence.</para> + </listitem> + </varlistentry> - <varlistentry> - <term><code>jta-data-source</code>, - <code>non-jta-data-source</code></term> + <varlistentry> + <term><code>jta-data-source</code>, + <code>non-jta-data-source</code></term> - <listitem> - <para>This is the JNDI name of where the javax.sql.DataSource is - located. When running without a JNDI available Datasource, you must - specify JDBC connections with Hibernate specific properties (see - below).</para> - </listitem> - </varlistentry> + <listitem> + <para>This is the JNDI name of where the javax.sql.DataSource is + located. When running without a JNDI available Datasource, you + must specify JDBC connections with Hibernate specific properties + (see below).</para> + </listitem> + </varlistentry> - <varlistentry> - <term> - <code>mapping-file</code> - </term> + <varlistentry> + <term> + <code>mapping-file</code> + </term> - <listitem> - <para>The class element specifies a EJB3 compliant XML mapping file - that you will map. This feature is currently not supported.</para> - </listitem> - </varlistentry> + <listitem> + <para>The class element specifies a EJB3 compliant XML mapping + file that you will map. This feature is currently not + supported.</para> + </listitem> + </varlistentry> - <varlistentry> - <term> - <code>jar-file</code> - </term> + <varlistentry> + <term> + <code>jar-file</code> + </term> - <listitem> - <para>The jar-file elements specifies a jar to analyse. All properly - annotated classes, annotated packages and all hbm.xml files part of - this jar file will be added to the persistence unit configuration. - This element is mainly used in Java EE environment. Use of this one - in Java SE should be considered as non portable, in this case a - absolute url is needed.</para> - </listitem> - </varlistentry> + <listitem> + <para>The jar-file elements specifies a jar to analyse. All + properly annotated classes, annotated packages and all hbm.xml + files part of this jar file will be added to the persistence unit + configuration. This element is mainly used in Java EE environment. + Use of this one in Java SE should be considered as non portable, + in this case a absolute url is needed.</para> + </listitem> + </varlistentry> - <varlistentry> - <term> - <code>exclude-unlisted-classes</code> - </term> + <varlistentry> + <term> + <code>exclude-unlisted-classes</code> + </term> - <listitem> - <para>Do not check the main jar file for annotated classes. Only - explicit classes will be part of the persistence unit.</para> - </listitem> - </varlistentry> + <listitem> + <para>Do not check the main jar file for annotated classes. Only + explicit classes will be part of the persistence unit.</para> + </listitem> + </varlistentry> - <varlistentry> - <term> - <code>class</code> - </term> + <varlistentry> + <term> + <code>class</code> + </term> - <listitem> - <para>The class element specifies a fully qualified class name that - you will map. By default all properly annotated classes and all - hbm.xml files found inside the archive are added to the persistence - unit configuration. You can add some external entity through the - class element though. As an extension to the specification, you can - add a package name in the <literal><class></literal> element - (eg - <code><class>org.hibernate.eg</class></code>).</para> - </listitem> - </varlistentry> + <listitem> + <para>The class element specifies a fully qualified class name + that you will map. By default all properly annotated classes and + all hbm.xml files found inside the archive are added to the + persistence unit configuration. You can add some external entity + through the class element though. As an extension to the + specification, you can add a package name in the + <literal><class></literal> element (eg + <code><class>org.hibernate.eg</class></code>).</para> + </listitem> + </varlistentry> - <varlistentry> - <term> - <code>properties</code> - </term> + <varlistentry> + <term> + <code>properties</code> + </term> - <listitem> - <para>The properties element is used to specify vendor specific - properties. This is where you will define your Hibernate specific - configurations. This is also where you will have to specify JDBC - connection information as well.</para> - </listitem> - </varlistentry> - </variablelist> + <listitem> + <para>The properties element is used to specify vendor specific + properties. This is where you will define your Hibernate specific + configurations. This is also where you will have to specify JDBC + connection information as well.</para> + </listitem> + </varlistentry> + </variablelist> - <para>The EJB3 specification defines a bootstrap procedure to access the - <classname>EntityManagerFactory</classname> and the - <classname>EntityManager</classname>. The bootstrap class is - <classname>javax.persistence.Persistence</classname>, e.g.</para> + <para>Be sure to define the grammar definition in the + <literal>persistence</literal> element since the EJB3 specification + requires the schema validation. If the systemId ends with + <literal>persistence_1_0.xsd</literal>, Hibernate entityManager will use + the version embedded in the hibernate-entitymanager.jar. No internet + access will be processed.</para> - <programlisting>EntityManagerFactory emf = Persistence.createEntityManagerFactory("manager1"); + <programlisting><persistence xmlns="http://java.sun.com/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" + version="1.0"></programlisting> + </section> + + <section id="setup-configuration-bootstrapping"> + <title>Bootstrapping</title> + + <para>The EJB3 specification defines a bootstrap procedure to access the + <classname>EntityManagerFactory</classname> and the + <classname>EntityManager</classname>. The bootstrap class is + <classname>javax.persistence.Persistence</classname>, e.g.</para> + + <programlisting>EntityManagerFactory emf = Persistence.createEntityManagerFactory("manager1"); //or Map configOverrides = new HashMap(); configOverrides.put("hibernate.hbm2ddl.auto", "create-drop"); EntityManagerFactory programmaticEmf = Persistence.createEntityManagerFactory("manager1", configOverrides);</programlisting> - <para>The first version is equivalent to the second with an empty map. The - map version is a set of overrides that will take precedence over any - properties defined in your persistence.xml files. There are a couple of - EJB3 properties usable in the map:</para> + <para>The first version is equivalent to the second with an empty map. + The map version is a set of overrides that will take precedence over any + properties defined in your persistence.xml files. There are a couple of + EJB3 properties usable in the map:</para> - <itemizedlist> - <listitem> - <para>javax.persistence.provider to define the provider class - used</para> - </listitem> + <itemizedlist> + <listitem> + <para>javax.persistence.provider to define the provider class + used</para> + </listitem> - <listitem> - <para>javax.persistence.transactionType to define the transaction type - used (either JTA or RESOURCE_LOCAL)</para> - </listitem> + <listitem> + <para>javax.persistence.transactionType to define the transaction + type used (either JTA or RESOURCE_LOCAL)</para> + </listitem> - <listitem> - <para>javax.persistence.jtaDataSource to define the JTA datasource - name in JNDI</para> - </listitem> + <listitem> + <para>javax.persistence.jtaDataSource to define the JTA datasource + name in JNDI</para> + </listitem> - <listitem> - <para>javax.persistence.nonJtaDataSource to define the non JTA - datasource name in JNDI</para> - </listitem> - </itemizedlist> + <listitem> + <para>javax.persistence.nonJtaDataSource to define the non JTA + datasource name in JNDI</para> + </listitem> + </itemizedlist> - <para>When <code>Persistence.createEntityManagerFactory()</code> is - called, the persistence implementation will search your classpath for any - <code>META-INF/persistence.xml</code> files using the - <code>ClassLoader.getResource("META-INF/persistence.xml")</code> method. - From this list of resources, it will try to find an entity manager that - matches the name you specify in the command line with what is specified in - the persistence.xml file. If no persistence.xml with the correct name are - found, a <classname>PersistenceException</classname> is raised. If there - is only one persistence.xml in your classpath, you don't have to declare - any entity manager factory name (however, if several files are found, a - <literal>PersistenceException</literal> is raised).</para> + <para>When <code>Persistence.createEntityManagerFactory()</code> is + called, the persistence implementation will search your classpath for + any <code>META-INF/persistence.xml</code> files using the + <code>ClassLoader.getResource("META-INF/persistence.xml")</code> method. + From this list of resources, it will try to find an entity manager that + matches the name you specify in the command line with what is specified + in the persistence.xml file. If no persistence.xml with the correct name + are found, a <classname>PersistenceException</classname> is + raised.</para> - <programlisting>EntityManagerFactory emf = Persistence.createEntityManagerFactory(null);</programlisting> + <para>Apart from Hibernate system-level settings, all the properties + available in Hibernate can be set in <code>properties</code> element of + the persistence.xml file or as an override in the map you pass to + <code>createEntityManagerFactory()</code>. Please refer to the Hibernate + reference documentation for a complete listing. There are however a + couple of properties available in the EJB3 provider only.</para> - <para>Apart from Hibernate system-level settings, all the properties - available in Hibernate can be set in <code>properties</code> element of - the persistence.xml file or as an override in the map you pass to - <code>createEntityManagerFactory()</code>. Please refer to the Hibernate - reference documentation for a complete listing. There are however a couple - of properties available in the EJB3 provider only.</para> + <para></para> - <para></para> + <table> + <title>Hibernate Entity Manager specific properties</title> - <table> - <title>Hibernate Entity Manager specific properties</title> + <tgroup cols="2"> + <colspec align="left" colname="c1" /> - <tgroup cols="2"> - <colspec align="left" colname="c1" /> + <colspec colname="c2" colwidth="2*" /> - <colspec colname="c2" colwidth="2*" /> + <thead> + <row> + <entry>Property name</entry> - <thead> - <row> - <entry>Property name</entry> + <entry>Description</entry> + </row> + </thead> - <entry>Description</entry> - </row> - </thead> + <tbody> + <row> + <entry>hibernate.ejb.classcache.<classname></entry> - <tbody> - <row> - <entry>hibernate.ejb.classcache.<classname></entry> + <entry>class cache strategy [comma cache region] of the class + Default to no cache, and default region cache to + fully.qualified.classname (eg. + hibernate.ejb.classcache.com.acme.Cat read-write or + hibernate.ejb.classcache.com.acme.Cat read-write, + MyRegion).</entry> + </row> - <entry>class cache strategy [comma cache region] of the class - Default to no cache, and default region cache to - fully.qualified.classname (eg. - hibernate.ejb.classcache.com.acme.Cat read-write or - hibernate.ejb.classcache.com.acme.Cat read-write, - MyRegion).</entry> - </row> + <row> + <entry>hibernate.ejb.collectioncache.<collectionrole></entry> - <row> - <entry>hibernate.ejb.collectioncache.<collectionrole></entry> + <entry>collection cache strategy [comma cache region] of the + class Default to no cache, and default region cache to + fully.qualified.classname.role (eg. + hibernate.ejb.classcache.com.acme.Cat read-write or + hibernate.ejb.classcache.com.acme.Cat read-write, + MyRegion).</entry> + </row> - <entry>collection cache strategy [comma cache region] of the class - Default to no cache, and default region cache to - fully.qualified.classname.role (eg. - hibernate.ejb.classcache.com.acme.Cat read-write or - hibernate.ejb.classcache.com.acme.Cat read-write, - MyRegion).</entry> - </row> + <row> + <entry>hibernate.ejb.cfgfile</entry> - <row> - <entry>hibernate.ejb.cfgfile</entry> + <entry>XML configuration file to use to configure Hibernate (eg. + <filename>/hibernate.cfg.xml</filename>).</entry> + </row> - <entry>XML configuration file to use to configure Hibernate (eg. - <filename>/hibernate.cfg.xml</filename>).</entry> - </row> + <row> + <entry>hibernate.archive.autodetection</entry> - <row> - <entry>hibernate.archive.autodetection</entry> + <entry>Determine which element is auto discovered by Hibernate + Entity Manager while parsing the .par archive. (default to + <literal>class,hbm</literal>).</entry> + </row> - <entry>Determine which element is auto discovered by Hibernate - Entity Manager while parsing the .par archive. (default to - <literal>class,hbm</literal>).</entry> - </row> + <row> + <entry>hibernate.ejb.interceptor</entry> - <row> - <entry>hibernate.ejb.interceptor</entry> + <entry>An optional Hibernate interceptor. This interceptor has + to implement <classname>org.hibernate.Interceptor</classname> + and have a no-arg constructor.</entry> + </row> - <entry>An optional Hibernate interceptor. This interceptor has to - implement <classname>org.hibernate.Interceptor</classname> and - have a no-arg constructor.</entry> - </row> + <row> + <entry>hibernate.ejb.naming_strategy</entry> - <row> - <entry>hibernate.ejb.naming_strategy</entry> + <entry>An optional naming strategy. The default naming strategy + used is <classname>EJB3NamingStrategy</classname>. You also + might want to consider the + <classname>DefaultComponentSafeNamingStrategy</classname>.</entry> + </row> - <entry>An optional naming strategy. The default naming strategy - used is <classname>EJB3NamingStrategy</classname>. You also might - want to consider the - <classname>DefaultComponentSafeNamingStrategy</classname>.</entry> - </row> + <row> + <entry>hibernate.ejb.event.<eventtype></entry> - <row> - <entry>hibernate.ejb.event.<eventtype></entry> + <entry>Event listener list for a given eventtype. The list of + event listeners is a comma separated fully qualified class name + list (eg. hibernate.ejb.event.pre-load + com.acme.SecurityListener, com.acme.AuditListener)</entry> + </row> - <entry>Event listener list for a given eventtype. The list of - event listeners is a comma separated fully qualified class name - list (eg. hibernate.ejb.event.pre-load com.acme.SecurityListener, - com.acme.AuditListener)</entry> - </row> + <row> + <entry>hibernate.ejb.use_class_enhancer</entry> - <row> - <entry>hibernate.ejb.use_class_enhancer</entry> + <entry>Whether or not use Application server class enhancement + at deployment time (default to false)</entry> + </row> - <entry>Whether or not use Application server class enhancement at - deployment time (default to false)</entry> - </row> - </tbody> - </tgroup> - </table> + <row> + <entry>hibernate.ejb.discard_pc_on_close</entry> - <para>Note that you can mix XML <literal><class></literal> - declaration and <literal>hibernate.ejb.cfgfile</literal> usage in the same - configuration. Be aware of the potential clashed. The properties set in - <filename>persistence.xml</filename> will override the one in the defined - <filename>hibernate.cfg.xml</filename>.</para> + <entry>Whether or not em.close() actually discard the + persistence context right away or wait for the transaction + completion defore discarding it (default to falseuse Application + server class enhancement at deployment time (default to false, + ie wait the transaction completion)</entry> + </row> + </tbody> + </tgroup> + </table> - <para>Here is a typical configuration in a J2SE environment</para> + <para>Note that you can mix XML <literal><class></literal> + declaration and <literal>hibernate.ejb.cfgfile</literal> usage in the + same configuration. Be aware of the potential clashed. The properties + set in <filename>persistence.xml</filename> will override the one in the + defined <filename>hibernate.cfg.xml</filename>.</para> - <programlisting><persistence> + <note> + <para>It is important that you do not override + <literal>hibernate.transaction.factory_class</literal>, Hibernate + EntityManager automatically set the appropriate transaction factory + depending on the EntityManager type (ie <literal>JTA</literal> versus + <literal>RESOURSE_LOCAL</literal>). If you are working in a Java EE + environment, you might want to set the + <literal>hibernate.transaction.manager_lookup_class</literal> + though.</para> + </note> + + <para>Here is a typical configuration in a J2SE environment</para> + + <programlisting><persistence> <persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL"> <class>org.hibernate.ejb.test.Cat</class> <class>org.hibernate.ejb.test.Distributor</class> @@ -360,16 +400,16 @@ <persistence-unit> </persistence></programlisting> - <para>To ease the programmatic configuration, Hibernate Entity Manager - provide a proprietary API. This API is very similar to the - <classname>Configuration</classname> API and share the same concepts: - <classname>Ejb3Configuration</classname>. Refer to the JavaDoc and the - Hibernate reference guide for more detailed informations on how to use - it.</para> + <para>To ease the programmatic configuration, Hibernate Entity Manager + provide a proprietary API. This API is very similar to the + <classname>Configuration</classname> API and share the same concepts: + <classname>Ejb3Configuration</classname>. Refer to the JavaDoc and the + Hibernate reference guide for more detailed informations on how to use + it.</para> - <para>TODO: me more descriptive on some APIs like setDatasource()</para> + <para>TODO: me more descriptive on some APIs like setDatasource()</para> - <programlisting>Ejb3Configuration cfg = new Ejb3Configuration(); + <programlisting>Ejb3Configuration cfg = new Ejb3Configuration(); EntityManagerFactory emf = cfg.configure("/mypath/hibernate.cfg.xml") //add a regular hibernate.cfg.xml .addProperties( properties ) //add some properties @@ -378,6 +418,7 @@ .addClass( NonAnnotatedClass.class ) //add an hbm.xml file using the Hibernate convention .addFile( "/mypath/MyOtherCLass.hbm.xml ) //add an hbm.xml file .createEntityManagerFactory(); //Create the entity manager factory</programlisting> + </section> </section> <section> @@ -533,7 +574,7 @@ <programlisting>// Use persistence.xml configuration EntityManagerFactory emf = Peristence.createEntityManagerFactory("manager1") -EntityManager em = emf.createEntityManager(); // Retrieve a transactional-scoped entity manager +EntityManager em = emf.createEntityManager(); // Retrieve an application managed entity manager // Work with the EM em.close(); ... @@ -543,19 +584,17 @@ initialization time and closed at application end. It's creation is an expensive process. For those who are familiar with Hibernate, an entity manager factory is very much like a session factory. Actually, an entity - manager factory is a wrapper on top of a session factory.</para> + manager factory is a wrapper on top of a session factory. Calls to the + entityManagerFactory are thread safe.</para> - <para>There are two kinds of entity managers. The transaction-scoped - entity manager (default) create and destroy a persistence context for each - transaction: in other words, the managed entities are detached once the - transaction ends. The extended entity manager keep the same persistence + <para>Thanks to the EntityManagerFactory, you can retrieve an extended + entity manager. The extended entity manager keep the same persistence context for the lifetime of the entity manager: in other words, the - entities are still managed between two transactions. - <code>emf.createEntityManager()</code> creates a transaction-scoped entity - manager and - <code>emf.createEntityManager(PersistenceContextType.EXTENDED)</code> - creates an extended entity manager. You can see an entity manager as a + entities are still managed between two transactions (unless you call + entityManager.clear() in between). You can see an entity manager as a small wrapper on top of an Hibernate session.</para> + + <para>TODO explains emf.createEntityManager(Map)</para> </section> <section> Modified: trunk/HibernateExt/ejb/doc/reference/en/modules/entitymanagerapi.xml =================================================================== --- trunk/HibernateExt/ejb/doc/reference/en/modules/entitymanagerapi.xml 2006-03-16 23:51:58 UTC (rev 9642) +++ trunk/HibernateExt/ejb/doc/reference/en/modules/entitymanagerapi.xml 2006-03-17 08:42:25 UTC (rev 9643) @@ -178,7 +178,7 @@ <programlisting>Iterator results = em.createQuery( "select cat.color, min(cat.birthdate), count(cat) from Cat cat " + "group by cat.color") - .list() + .getResultList() .iterator(); while ( results.hasNext() ) { @@ -229,7 +229,7 @@ <programlisting>Query q = em.createQuery("select cat from DomesticCat cat"); q.setFirstResult(20); q.setMaxResults(10); -List cats = q.list(); //return cats from the 20th position to 29th</programlisting> +List cats = q.getResultList(); //return cats from the 20th position to 29th</programlisting> <para>Hibernate knows how to translate this limit query into the native SQL of your DBMS.</para> @@ -249,7 +249,7 @@ <programlisting>Query q = em.createNamedQuery("eg.DomesticCat.by.name.and.minimum.weight"); q.setString(1, name); q.setInt(2, minWeight); -List cats = q.list();</programlisting> +List cats = q.getResultList();</programlisting> <para>Note that the actual program code is independent of the query language that is used, you may also define native SQL queries in @@ -271,7 +271,7 @@ mechanism to work):</para> <programlisting>@SqlResultSetMapping(name="getItem", entities = - @EntityResult(name="org.hibernate.ejb.test.Item", fields= { + @EntityResult(entityClass=org.hibernate.ejb.test.Item.class, fields= { @FieldResult(name="name", column="itemname"), @FieldResult(name="descr", column="itemdescription") }) @@ -378,13 +378,6 @@ <entry>Cache mode used for this query</entry> </row> - - <row> - <entry>org.hibernate.callable</entry> - - <entry>For native queries, whether or not the query is of type - callable or not (default to false)</entry> - </row> </tbody> </tgroup> </table> @@ -560,7 +553,7 @@ </section> <section> - <title>Flushing the persistence context</title> + <title>Flush the persistence context</title> <section> <title>In a transaction</title> @@ -635,13 +628,9 @@ <para>It is possible to change the default behavior so that flush occurs less frequently. The <classname>FlushModeType</classname> for an entity - manager defines three different modes: only flush at commit time, flush - automatically using the explained routine, or never flush unless - <methodname>flush()</methodname> is called explicitly. The last mode is - useful for long running extended perstence contexts, where the context - and its entity manager is kept open (but disconnected from the JDBC data - source) possibly for a long time. TODO: Add link to disconnection - discussion, however, disconnection is implementation specific.</para> + manager defines two different modes: only flush at commit time or flush + automatically using the explained routine unless + <methodname>flush()</methodname> is called explicitly.</para> <programlisting>em = emf.createEntityManager(); Transaction tx = em.getTransaction().begin(); @@ -659,20 +648,26 @@ <para>During flush, an exception might happen (e.g. if a DML operation violates a constraint). TODO: Add link to exception handling.</para> + + <para>Hibernate provides more flush modes than the one described in the + EJB3 specification. Please refer to the Hibernate core reference + documentation for more informations.</para> </section> <section> <title>Outside a transaction</title> - <para>When running an <literal>EXTENDED</literal> persistence context - outside a transaction, all the modification operations are queued (ie - not flushed to the database). This is actually done, by setting the - <literal>FlushMode</literal> to <literal>NONE</literal> when the Entity - Manager is executed outside an active transaction.</para> - - <para>When the transaction comes to an active state, the queued - operations are flushed to the database (by setting the - <literal>FlushMode</literal> to its previous state.</para> + <para>In an <literal>EXTENDED</literal> persistence context, all read + only operations of the entity manager can be executed outside a + transaction (<literal>find()</literal>, + <literal>getReference()</literal>, <literal>refresh()</literal>, and + read queries). Some modifications operations can be executed outside a + transaction, but they are queued until the persistence context join a + transaction. This is the case of <literal>persist()</literal>, + <literal><literal>merge()</literal></literal>, + <literal>remove()</literal>. Some operations cannot be called outside a + transaction: <literal>flush()</literal>, <literal>lock()</literal>, and + update/delete queries.</para> </section> </section> @@ -754,4 +749,29 @@ </listitem> </itemizedlist> </section> + + <section> + <title>Locking</title> + + <para>The default locking system in EJB3 is mostly based on optimistic + locking (ie using a version column to check any concurrency issues). EJB3 + has defined an additional mechanism to increase the concurrency + guaranties. You can apply a lock on a given entity (and it's associated + entities if <literal>LOCK</literal> is cascaded) through the + <methodname>lock(Object entity)</methodname> method. Depending on the + concurrency guaranties you requires, you choose a lock mode:</para> + + <itemizedlist> + <listitem> + <para><literal>LockMode.READ</literal> prevents dirty-reads and non + repeatable read on a given entity.</para> + </listitem> + + <listitem> + <para><literal>LockMode.WRITE</literal> prevents dirty-reads and non + repeatable read on a given entity and force an increase of the version + number if any.</para> + </listitem> + </itemizedlist> + </section> </chapter> \ No newline at end of file Modified: trunk/HibernateExt/ejb/doc/reference/en/modules/transactions.xml =================================================================== --- trunk/HibernateExt/ejb/doc/reference/en/modules/transactions.xml 2006-03-16 23:51:58 UTC (rev 9642) +++ trunk/HibernateExt/ejb/doc/reference/en/modules/transactions.xml 2006-03-17 08:42:25 UTC (rev 9643) @@ -21,7 +21,7 @@ match the concept of entity manager and persistence context. One is an API and programming object, the other a definition of scope. However, keep in mind the essential difference. A persistence context is usually bound to a - JTA transaction in J2EE, and a persistence context starts and ends at + JTA transaction in Java EE, and a persistence context starts and ends at transaction boundaries (transaction-scoped) unless you use an extended entity manager. Please refer to <xref linkend="architecture-ejb-persistctxscope" /> for more information.</para> @@ -80,13 +80,13 @@ two is one-to-one and this model is a perfect fit for many applications.</para> - <para>This is the default EJB3 persistence model in a J2EE environment - (JTA bounded, transaction-scoped persistence context); injected (or - looked up) entity managers share the same persistence context for a - particular JTA transaction. The beauty of EJB3 is that you don't have to - care about that anymore and just see data access through entity manager - and demaraction of transaction scope on session beans as completely - orthogonal.</para> + <para>This is the default EJB3 persistence model in a Java EE + environment (JTA bounded, transaction-scoped persistence context); + injected (or looked up) entity managers share the same persistence + context for a particular JTA transaction. The beauty of EJB3 is that you + don't have to care about that anymore and just see data access through + entity manager and demaraction of transaction scope on session beans as + completely orthogonal.</para> <para>The challenge is the implementation of this (and other) behavior outside an EJB3 container: not only has the @@ -209,24 +209,6 @@ the context of optimistic concurrency control.</para> <para>TODO: This note should probably come later.</para> - - <note> - - - <title>Recommended approach</title> - - - - <para>The - <emphasis>entitymanager-per-application-transaction</emphasis> is - avaliable out-of-the-box in an EJB3 container using a Stateful Session - Bean that keeps the state of an extended entity manager and its - persistence context. To enable this extended persistence context, - annotate your bean as - <literal>@PersistenceContext(EXTENDED).</literal></para> - - TODO: What exactly am I supposed to do? This is incomplete... - </note> </sect2> <sect2 id="transactions-basics-identity"> @@ -379,7 +361,7 @@ non-managed environment, an <literal>EntityManagerFactory</literal> is usually responsible for its own database connection pool. The application developer has to manually set transaction boundaries, in other words, - begin, commit, or rollback database transactions himself. A managed + begin, commit, or rollback database transactions itself. A managed environment usually provides container-managed transactions, with the transaction assembly defined declaratively through annotations of EJB session beans, for example. Programmatic transaction demarcation is then @@ -396,8 +378,8 @@ </listitem> <listitem> - <para>close the entity manager (if running outside an EJB3 - container)</para> + <para>close the entity manager (if using an application-managed entity + manager)</para> </listitem> <listitem> @@ -429,7 +411,7 @@ tx.commit(); } catch (RuntimeException e) { - if (tx != null) tx.rollback(); + if ( tx != null && tx.isActive() ) tx.rollback(); throw e; // or display error message } finally { @@ -455,6 +437,36 @@ yourself and you should use J2EE/EJB container services whenever they are available. Exception handling is discussed later in this chapter.</para> + + <sect3> + <title>EntityTransaction</title> + + <para>In a JTA environment, you don't need any extra API to interact + with the transaction in your environment. Simply use transaction + declaration or the JTA APIs.</para> + + <para>If you are using a <literal>RESOURCE_LOCAL</literal> entity + manager, you need to demarcate your transaction boundaries through the + <literal>EntityTransaction</literal> API. You can get an + <literal>EntityTransaction</literal> through + <literal>entityManager.getTransaction()</literal>. This + <literal>EntityTransaction</literal> API provides the regular + <methodname>begin()</methodname>, <methodname>commit()</methodname>, + <methodname>rollback()</methodname> and + <methodname>isActive()</methodname> methods. It also provide a way to + mark a transaction as rollback only, ie force the transaction to + rollback. This is very similar to the JTA operation + <methodname>setRollbackOnly()</methodname>. When a + <literal>commit()</literal> operation fail and/or if the transaction + is marked as <literal>setRollbackOnly()</literal>, the + <literal>commit()</literal> method will try to rollback the + transaction and raise a + <literal>javax.transaction.RollbackException</literal>.</para> + + <para>In a <literal>JTA</literal> entity manager, + <literal>entityManager.getTransaction()</literal> calls are not + permitted.</para> + </sect3> </sect2> <sect2 id="transactions-demarcation-jta"> @@ -469,9 +481,6 @@ <para>If you use bean-managed transactions (BMT), the code will look like this:</para> - <para>TODO: Check if UserTransaction is now really rollback() and not - setRollbackOnly()</para> - <programlisting>// BMT idiom @Resource public UserTransaction utx; @Resource public EntityManagerFactory factory; @@ -506,15 +515,9 @@ as per the EJB specification (system exception vs. application exception).</para> - <para>TODO: Check if this configuration is still the same for EJB3 - entity manager factory</para> - - <para>Note that you should choose - <literal>org.hibernate.transaction.JTATransactionFactory</literal> in a - BMT session bean, and - <literal>org.hibernate.transaction.CMTTransactionFactory</literal> in a - CMT session bean, when you configure Hibernate's transaction factory. - Remember to also set + <para>It is important to let Hibernate EntityManager define the + <literal>hibernate.transaction.factory_class</literal> (ie not + overriding this value). Remember to also set <literal>org.hibernate.transaction.manager_lookup_class</literal>.</para> <para>If you work in a CMT environment, you might also want to use the @@ -523,26 +526,18 @@ variable to hold the entity manager, but a single EJB request might execute in different threads (e.g. session bean calling another session bean). The EJB3 container takes care of the persistence context - propagation for you. Either using injection or using - <methodname>EntityManagerFactory.getEntityManager()</methodname>, the - EJB3 container will return an entity manager with the same persistence + propagation for you. Either using injection or lookup, the EJB3 + container will return an entity manager with the same persistence context bound to the JTA context if any, or create a new one and bind it (see <xref linkend="architecture-ejb-persistctxpropagation" /> .)</para> <para>Our entity manager/transaction management idiom for CMT and EJB3 container-use is reduced to this:</para> - <programlisting>// CMT idiom through factory -EntityManager em = factory.getEntityManager(); + <programlisting>//CMT idiom through injection +@PersistenceContext(name="sample") EntityManager em;</programlisting> -// do some work -... - -/ /CMT idiom through injection -@Resource EntityManager em;</programlisting> - - <para>In other words, all you have to do in a managed environment is - call <literal>EntityManagerFactory.getEntityManager()</literal> or + <para>In other words, all you have to do in a managed environment is to inject the <literal>EntityManager</literal>, do your data access work, and leave the rest to the container. Transaction boundaries are set declaratively in the annotations or deployment descriptors of your @@ -662,6 +657,86 @@ </sect2> </sect1> + <sect1> + <title>EXTENDED Persistence Context</title> + + <para>All application managed entity manager and container managed + persistence contexts defined as such are <literal>EXTENDED</literal>. This + means that the persistence context type goes beyond the transaction life + cycle. We should then understand what happens to operations made outside + the scope of a transaction.</para> + + <para>In an <literal>EXTENDED</literal> persistence context, all read only + operations of the entity manager can be executed outside a transaction + (<literal>find()</literal>, <literal>getReference()</literal>, + <literal>refresh()</literal>, and read queries). Some modifications + operations can be executed outside a transaction, but they are queued + until the persistence context join a transaction: this is the case of + <literal>persist()</literal>, + <literal><literal>merge()</literal></literal>, + <literal>remove()</literal>. Some operations cannot be called outside a + transaction: <literal>flush()</literal>, <literal>lock()</literal>, and + update/delete queries.</para> + + <sect2> + <title>Container Managed Entity Manager</title> + + <para>When using an EXTENDED persistence context with a container + managed entity manager, the lifecycle of the persistence context is + binded to the lifecycle of the Stateful Session Bean. Plus if the entity + manager is created outside a transaction, modifications operations + (persist, merge, remove) are queued in the persistence context and not + executed to the database.</para> + + <para>When a method of the stateful session bean involved or starting a + transaction is later called, the entity manager join the transaction. + All queued operation will then be executed to synchronize the + persistence context.</para> + + <para>This is perfect to implement the + <literal>entitymanager-per-conversation</literal> pattern. A stateful + session bean represents the conversation implementation. All + intermediate conversation work will be processed in methods not + involving transaction. The end of the conversation will be processed + inside a <literal>JTA</literal> transaction. Hence all queued operations + will be executed to the database and commited. If you are interested in + the notion of conversation inside your application, have a look at JBoss + Seam. Jboss Seam emphasizes the concept of conversation and entity + manager lifecycle and bind EJB3 and JSF together.</para> + </sect2> + + <sect2> + <title>Application Managed Entity M... [truncated message content] |
From: <hib...@li...> - 2006-03-16 23:52:18
|
Author: epbernard Date: 2006-03-16 18:51:58 -0500 (Thu, 16 Mar 2006) New Revision: 9642 Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/DistrictUser.java Log: better test Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/DistrictUser.java =================================================================== --- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/DistrictUser.java 2006-03-16 22:19:13 UTC (rev 9641) +++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/DistrictUser.java 2006-03-16 23:51:58 UTC (rev 9642) @@ -1,25 +1,21 @@ package org.hibernate.test.annotations.manytoone; import java.util.Date; - import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinColumns; import javax.persistence.ManyToOne; -import javax.persistence.SequenceGenerator; import javax.persistence.Table; @Entity @Table(name = "CLRUS2DI") -@SequenceGenerator(name = "DistrictUserSeq", sequenceName = "SQ_DISTRICT_USER") public class DistrictUser { @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "DistrictUserSeq") + @GeneratedValue @Column(name = "CLRUS2DI_KEY") private Long id; |
Author: epbernard Date: 2006-03-16 17:19:13 -0500 (Thu, 16 Mar 2006) New Revision: 9641 Modified: trunk/HibernateExt/metadata/ trunk/HibernateExt/metadata/doc/reference/en/master.xml trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml trunk/HibernateExt/metadata/doc/reference/en/modules/setup.xml trunk/HibernateExt/metadata/doc/reference/en/modules/validator.xml trunk/HibernateExt/metadata/lib/ejb3-persistence.jar trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazin.java trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazinPk.java trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java Log: Documentation tests and ejb3 persistence api sync Property changes on: trunk/HibernateExt/metadata ___________________________________________________________________ Name: svn:ignore - target build build.properties test_output testout common-build.xml javadoc.bat build.properties instrumenttestout + target build build.properties test_output testout common-build.xml javadoc.bat build.properties instrumenttestout classes Modified: trunk/HibernateExt/metadata/doc/reference/en/master.xml =================================================================== --- trunk/HibernateExt/metadata/doc/reference/en/master.xml 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/doc/reference/en/master.xml 2006-03-16 22:19:13 UTC (rev 9641) @@ -12,7 +12,7 @@ <subtitle>Reference Guide</subtitle> - <releaseinfo>3.1 beta 8</releaseinfo> + <releaseinfo>3.1 beta 9</releaseinfo> <mediaobject> <imageobject> @@ -59,12 +59,11 @@ complete set of ORM annotations, including EJB3 standard annotations as well as Hibernate3 extensions for cases not covered by the specification. Eventually you will be able to create all possible mappings with - annotations. See the <xref linkend="compliance" /> section for more - information.</para> + annotations. See the JIRA road mapsection for more information.</para> <para>The EJB3 Public final draft has change some annotations, please - refer to http://www.hibernate.org/371.html as a migration guide between Hibernate Annotations 3.1beta7 - and 3.1beta8.</para> + refer to http://www.hibernate.org/371.html as a migration guide between + Hibernate Annotations 3.1beta7 and 3.1beta8.</para> </preface> &setup; @@ -75,299 +74,4 @@ &lucene; - <appendix> - <title id="compliance">Compliance and limitations</title> - - <para>Issue tracking numbers can be looked up in JIRA on - http://www.hibernate.org/ if you want to verify the current state.</para> - - <synopsis>3.1beta8 Preview (20-01-2006) ------------------------------ -** Bug - * [ANN-132] - transient fields are considered to be persistent when not annotated with @Transient - * [ANN-162] - OneToMany mapping from annotated to hbm loaded class fails with infinite loop - * [ANN-175] - extractType executed on @Transient and fail when the return type is <T extends MembershipData> T - * [ANN-176] - Endless loop when annotated class references by ManyToOne class mapped in .hbm.xml - * [ANN-177] - unable to use referencedColumnName = joined subclass primary column name - * [ANN-178] - Different handling column naming with @JoinColumn between 3.1beta5 and 3.1beta7 - * [ANN-180] - Indexed collection, field access, onetomany+mappedby seems to fail - * [ANN-187] - Unable to referenceColumnName a column (property) of the super class - * [ANN-193] - @IdClass should work on @MappedSuperclass - * [ANN-199] - NPE when mappedBy property is wrong on a @OneToOne - * [ANN-214] - Annotation website documentation syntax error - -** New Feature - * [ANN-147] - Allow embeddable subclasses in the middle of a class hierarchy - * [ANN-172] - Delegates the SQL type of enum to @Enumerated - * [ANN-188] - @Email for validator - * [ANN-190] - @TableGenerator as per the pfd instead of @GeneratorIdTable & co - * [ANN-191] - Non entity classes in between entity classes in the hierarchy - * [ANN-200] - Support of @Basic, @Lob, @Enumerated, @Temporal as per the PFD - * [ANN-209] - @Named(Native)Query(hints=...) - - -** Improvement - * [ANN-17] - Support dotted annotation when declaring resultsets - * [ANN-56] - @AccessType: Support mixed field/property access strategies for an Entity - * [ANN-192] - Access type guessed from position of @Id or @EmbeddedId - * [ANN-194] - Access type guessed from owner entity for Embeddable objects - * [ANN-198] - Better error message when @ManyToOne references an unknown entity - * [ANN-201] - Rename @EmbeddableSuperclass into @MappedSuperclass - * [ANN-203] - Move to @Id @GeneratedValue(strategy=AUTO, generator="blah") - * [ANN-204] - @TableGenerator instead of @TableGenerator and @GeneratedIdTable - * [ANN-205] - @NamedQuery(query=...) instead of @NamedQuery(queryString=...) same for @NamedNativeQuery - * [ANN-215] - Support SqlResutSetMapping with dotted notation in arbitrary order - * [ANN-216] - Support scalar queries through @ColumnResult - * [ANN-218] - @SecondaryTable(PrimaryKeyJoinColumn[] pkJoinColumns) instead of @SecondaryTable(JoinColumn[] joins() ) - * [ANN-219] - @JoinTable(name, catalog, schema, uniqueConstraints) instead of @JoinTable(table=@Table()) - * [ANN-220] - @Column(table=) and @JoinColumn(table=) instead of @Column(secondaryTable=) - * [ANN-221] - @Inheritance(strategy), @DiscriminatorColumn(discriminatorType), @DiscriminatorValue instead of @Inheritance - * [ANN-225] - @EntityListeners replace @EntityListener - -3.1beta7 Preview (13-12-2005) ------------------------------ - -** Bug - * [ANN-114] - NPE when SecondaryTable uses a non pk reference column in @JoinColumn - * [ANN-115] - @Index does not work on joincolumns - * [ANN-117] - setOrphanDelete not set causing some delete-orphan .clear() to fail - * [ANN-123] - Support for Generics superclass - * [ANN-124] - FIELD constant thing is wrong in the doc - * [ANN-133] - Bytecode enhancement process adds non-transient properties to beans - * [ANN-135] - Inconsistent range check between Range Validator class and generated DDL. - * [ANN-136] - Validator annotations not applied to the hibernate metamodel for id properties - * [ANN-139] - SINGLE_TABLE inheritance raise an WrongClassException under certain circumstances - * [ANN-142] - Automatic Generation of Composite IDs - Annonation declaration fails - * [ANN-151] - <subclass extends= broken when using AnnotationConfiguration - * [ANN-152] - Indexes generated by the LuceneEventListener are deleted at startup (Mattias Arbin) - * [ANN-156] - MapKey Cannot Map @Id when using @IdClass - * [ANN-165] - @Length(min=4) ie wo max generate a varchar(Integer.MAX_VALUE) - * [ANN-171] - Class cast exception during processing of non getter generic methods - * [ANN-173] - ClassValidator.getInvalidValues should not depend on equals() for circularity check - -** New Feature - * [ANN-111] - add function for validating properties before bean creation - * [ANN-116] - fetch validators from implemented interfaces - * [ANN-125] - Validator does not preserve method hierarchy in InvalidValue[] - * [ANN-127] - Add @Future - * [ANN-128] - Externalize EJB3 namings to NamingStrategy - - -** Improvement - * [ANN-119] - Embedded international error messages - * [ANN-121] - Named Queries should be package level visible - * [ANN-126] - mention usage of columnDefinition as part of @Column in docs - * [ANN-138] - Support collections of value types with separate annotation - * [ANN-148] - EnumType should be aware of DababaseMetadata.storesUpperCaseIdentifiers() and co (Tim Fennell) - * [ANN-149] - Do not check lazy/uninitialized fields in Validator - * [ANN-153] - Customize the parent directory for indexes generated by LuceneEventListener (Mattias Arbin) - * [ANN-154] - Customize Analyzer subclass for the LuceneEventListener (Mattias Arbin) - * [ANN-168] - @FilterDef should support condition - * [ANN-170] - Keep user order of hbm files (to ease the typedef usage) - - -3.1beta6 Preview (06-10-2005) ------------------------------ - * ANN-105 More exception handling in AnnotationConfiguration - * ANN-109 @Index does not support join columns references - * ANN-93 Make Hibernate Validator Serializable Friendly - -3.1beta5 Preview (14-09-2005) ------------------------------ - * ANN-70 Lucene integration - * ANN-13 Support for referencedColumnName referencing non PK columns for @ManyToMany - * ANN-63 Use metadata.getUserName() when guessing Enum backing type (Scott Haug) - * ANN-38 Finish the optional=false support - * ANN-69 Expand the resource bundle message itself in the Validator framework - * ANN-68 Apply validator on a particular property (Jesus Marin) - * ANN-41 Allow field validations and validate private method (Chris Wood) - * ANN-75 Support named (native) query parameters (from Carlos Gonzalez) - * ANN-73 Use an eager strategy for the second join of a ManyToMany - * ANN-74 Allow configuration artefacts (hbm, classes) loading precedence - * ANN-79 Support collection of composite elements - * ANN-19 Annotations should support collections of primitive and core types - * ANN-77 Support primitive arrays - * ANN-20 Support dotted annotation when using overriding (Alexei Akhounov) - * ANN-55 @Proxy annotation should take proxyClass argument - * ANN-2 Bidirectional true @OneToOne - * ANN-80 @NotFound(action=NotFoundAction.IGNORE) - * ANN-57 @Table ignores unique contraint in association table - * ANN-3 Support of component inside SecondaryTable - * ANN-87 @InheritanceJoinColumn rename is incomplete - * ANN-81 ColumnDefinition not assigned when using @Column and @JoinColumn - * ANN-34 Second passes binded to HbmBinder.SecondPass - * NPE on Index and Unique constrains when column name has case inconsistency - * ANN-86 @Index not used on properties having no @Column - * ANN-49 Super class of Embeddable not mapped correctly (Alexei Akhounov) - * ANN-66 Null enums don't store to database correctly - * ANN-65 Validator ignores components (the DDL still ignores it) - * ANN-60 NPE when @EmbeddableSuperclass has a superclass @Entity - * ANN-90 mention usage of @Column together with @Id explicitly - * ANN-18 Document bean-level validator mecanism - -3.1beta4 Preview (04-08-2005) ------------------------------ - * ANN-54 EnumType fails to find the Enum in setParameterValues(Properties) - * ANN-32 Support index creation - * ANN-22 Hibernate 3 Annotations should support all Id generators - * ANN-51 redeclaring id in entity subclass raises ClassCastException - * ANN-43 @MapKey throw exception if key is id or a component subproperty - * ANN-52 Exception when @OrderBy contains the id property or a component subproperty - * ANN-13 Support for referencedColumnName referencing non PK columns for @ManyToOne, @OneToOne and @OneToMany - * ANN-46 Raise a warning on @Filter on subclasses - * ANN-48 @UniqueConstraint reorders columns (Chris Wood) - * ANN-6 enum did not worked for enums persisted in string based columns (MySql and Oracle) - * ANN-8 array of primitive no longer create a non null column - * ANN-45 Proper support for @Basic byte[] - * ANN-44 Don't mandate to list embedded superclasses - * ANN-42 Don't mandate resultset to be defined before named native queries - * ANN-11 More robust support for enum persistence (wider range of SQL types) - * HBX-307 Remove @Serialized and support @Lob tagging of a serializable type - -3.1beta3 (24-06-2005) ------------------------------ - * Rename @AssociationTable to @JoinTable - * HBX-213 support of @IdClass - * change targetEntity from String to Class - * HBX-305 Support Java5 Enums - * Add @Basic(optional=false) and Lob(optional=false) - * HBX-284 AnnotationOverride in inheritance in conjunction with @EmbeddedSuperclass - * HBX-304 @AttributeOverride instead of @Embedded(override=@AttributeOverride) or @EmbeddedId(...) - * HBX-290 All collection binder exception now show the collection role - * HBX-299 Fix test suite error on MySql - * HBX-302 @MapKey(name="propertyName") to map a map using a property of the associated class as a map key - * HBX-201 @Formula on properties or fields. - * Support @EntityResult(discriminatorColumn) - * Relax List usage as per the spec (non indexed list are defaulted to bag semantic) - * HBX-300 enable HQL order by fragment using @javax.persistence.OrderBy - * HBX-298 FKs on association tables are forced not null - * HBX-297 Primitive types creates a non null constrained column if defaulted and not SINGLE_TABLE (HBX-301) - * HBX-287 @DiscriminatorFormula - * HBX-205 @OnDelete(action=OnDeleteAction.CASCADE) for joined subclasses and collections - * Change @OneToOne(usePkasFk=true) into @PrimaryKeyJoinColumn - * Rename @InheritanceJoinColumn/@InheritanceJoinColumns to @PrimaryKeyJoinColumn/@PrimaryKeyJoinColumns - * Support @Basic(temporalType=...) - * HBX-282 protect @ManyToMany from abusive not joined filters - * Align with @NamedNativeQuery/@NamedNativeQueries - * HBX-283 Better getter resolution - * HBX-75 Implicit inheritance join columns declaration in composite PK - * HBX-54 Explicit exception when @Id is missing - * HBX-210 Fix NPE when the @Id was on the superclass of the root entity in conjonction with @OneToOne use - * HBX-280/HBX-157 Support @EmbeddabledSuperclass - -3.0beta2 Preview (26-05-2005) ------------------------------ - * Add the validate framework and bind it to the annotation binder. - * HBX-199 Support @Columns and thus multi-column properties (ie composite user types) - * HBX-206 Support @OrderBy and @Sort - * HBX-203/HBX-81 Support Hibernate cascade strategies through @Cascade (Pablo Nussembaum) - * HBX-47 Persist is cascaded on flush operation when using the EJB3 event listeners - * HBX-125 Support for named native SQL queries (not Scalar results) - * HBX-225 @Type annotation now work for @Id and @Version (Pablo Nussembaum, Emmanuel Bernard) - * HBX-248 TABLE_PER_CLASS no longer limited to leaf entities and use union-subclass as its strategy - * HBX-186 inheritance strategy no longer have to be defined on every entity (only on root entry) - * HBX-53 Annotated classes can be defined in any arbitrary order - * Support Array through @IndexColumn (Anthony Patricio) - * HBX-216 Ignore static fields and properties - * HBX-229/HBX-134 Filter javac generated methods that compensate type erasure aka bridge method (Rogo Gatto) - * HBX-184 Support List mappings through @IndexColumn (Matthiew Inger, Emmanuel Bernard) - * HBX-187 Move to a CollectionBinder structure (Matthiew Inger, Emmanuel Bernard) - * Fix of CascadeType.REMOVE - -3.0beta1 Preview (07-04-2005) based on the EJB3 Early Draft 2 -------------------------------------------------------------- - * support parameters in @Type (HBX-197) - * support @TypeDef at package and class level - * HBX-166 support @Lob for Character[],char[], String, byte[] and Byte[] (experimental) - * HBX-159/HBX-140 add @Filter(s) and @FilterDef(s) (Matthew Inger, Magnus Sandberg) - * HBX-44 @OneToOne support composite PK - * @OneToOne is supported except for true bidirectional @OneToOne - * Add @Cache annotation: allow to define caching on root entities and on collections (,eg @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL, region="specificCacheRegion") ) - * Support @OneToMany default (ie using an association table) - * HBX-164 insertable/updatable of @JoinColumn now work in @ManyToOne processing (Mario Ivankovits, Emmanuel Bernard) - * HBX-153 @Id(generate=GeneratorType.AUTO, generator="my_potential_sequence") now work (Pablo Nussembaum) - * Support @ManyToMany wo @AssociationTable (ie defaults) - * Support @ManyToMany(mappedBy) - * Support @OneToMany(mappedBy) (no JoinColumn needed on the @OneToMany side) - * Appropriate default value when no @JoinColumn is defined in a ManyToOne - * rename @GeneratorTable to @GeneratedIdTable - * rename CREATE to PERSIST, add REFRESH cascade style - * support Mapping Defaults for Non-Relationship Fields or Properties algorithm as defined in the EJB3 spec - * support @Serialized - * support @Lob for java.sql.Clob and java.sql.Blob - * allow embedded object declaration wo @Embeddable (if @Embedded or @EmbeddedId is present in the property) - * support for @EmbeddedId - * rename DependentAttribute to AttributeOverride, Dependent to Embedded and DependentObject to Embeddable - * support @ManyToOne in embedded objects - * support for @NamedQuery and @NamedQueries (EJBQL) - * move javax.ejb.* into javax.persistence.* and update copyright header - -3.0alpha3 (28-02-2005) ----------------------- -* HBX-116 Support for Where clause in classes and collections @Where(clause="") -* HBX-115 Support for class proxying configuration: @Proxy(lazy=false, proxyClassName="my.Interface") -* HBX-88 Support for hibernate type abstraction through @Type (only on basic properties for now) -* HBX-108 Support @BatchSize(size=n) for entities and collections -* HBX-107 implements @org.hibernate.annotations.Entity -* HBX-103 handle abstract classes -* HBX-83 precision & scale support for column (Bogdan Ghidireac) - -3.0alpha2 (25-01-2005) ----------------------- -* HBX-61 Support for @UniqueConstraint (except primaryKey=true) -* HBX-60 Support for a proper @TableGenerator (using MultipleHiLoPerTableGenerator) -* HBX-63 Support @GeneratorTable -* HBX-68 Add declarative configuration of annotated classes -* HBX-74 Rollback the HB-1315 fix: dialect no longer have to be set in hibernate.properties - - -Hibernate-annotations-3.0alpha1 based on the EJB3 Early Draft 1 (6.01.2005) ---------------------------------------------------------------------------- -* Support for EJB3 annotations: - - @Transient - - @Column (not primaryKey) - - @JoinColumn (referencedColumnName - only for a reference to a PK, not primaryKey) - - @Version - - @Basic - - @Entity - - @Table (not uniqueConstraints) - - @AccessType - - @Id - - @CascadeType - - @FetchType - - @GeneratorType (NONE, IDENTITY, TABLE, SEQUENCE) - - @TableGenerator (with scope visibility) - - @SequenceGenerator (with scope visibility, does not support initialValue() and allocationSize()) - - *not* @GeneratorTable (will have to write a new TableHiloGenerator, but it can wait) - - @ManyToOne (not optional) - - @OneToMany (Set and Collection, generics version or not, JoinColumn not guessed) - - @OneToOne - but not optional - no composite PK/FK - - @ManyToMany - - @AssociationTable (Has to be on both sides) - - @Inheritance - - @InheritanceType (has to be defined on every classes of the hierarchy for JOINED strategy, - not very clear about the TABLE_PER_CLASS strategy) - - @DiscriminatorColumn - - @DiscriminatorType - - @InheritanceJoinColumn - - @InheritanceJoinColumns - this annotation for Composite PK Entities has to be explicit, I do not respect the implicit semantic of the EJB3 spec - - @SecondaryTable (@OneToMany @JoinColumn(secondaryTable="..." does not work yet due to H3 core issue HHH-36 - - @SecondaryTables - this annotation for Composite PK Entities has to be explicit, I do not respect the implicit semantic of the EJB3 spec - - @DependentObject - - @Dependent - - @DependentAttribute (only for basic properties as per the spec) - - @Id in conjunction with @DependentObject (composite primary keys) - - @JoinColumns in conjunction with @ManytoOne, @OneToMany, @ManytoMany - - note that the composite FK columns have to be in the same table (no != secondary tables). This is probably a weird case and certainly a not recommanded one. - - -Still missing or incomplete features compared to the EJB3 spec --------------------------------------------------------------- - - support for initialValue and allocationSize in @SequenceGenerator (HBX-59) -</synopsis> - </appendix> </book> \ No newline at end of file Modified: trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml =================================================================== --- trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/doc/reference/en/modules/entity.xml 2006-03-16 22:19:13 UTC (rev 9641) @@ -262,7 +262,7 @@ </listitem> <listitem> - <para>annotated with <literal>@Temporal</literal></para> + <para>annotated with <literal>@Temporal</literal></para> </listitem> <listitem> @@ -440,12 +440,11 @@ <para>The <literal>Person</literal> entity bean has two component properties, <literal>homeAddress</literal> and - <literal>bornIn</literal>. Note that the - <literal>homeAddress</literal> property has not been annotated. - Hibernate will guess that it is a persistent component by looking for - the <literal>@Embeddable</literal> annotation in the Address class. We - also override the mapping of a column name (to - <literal>bornCountryName</literal>) with the + <literal>bornIn</literal>. <literal>homeAddress</literal> property has + not been annotated, but Hibernate will guess that it is a persistent + component by looking for the <literal>@Embeddable</literal> annotation + in the Address class. We also override the mapping of a column name + (to <literal>bornCountryName</literal>) with the <literal>@Embedded</literal> and <literal>@AttributeOverride </literal>annotations for each mapped attribute of <literal>Country</literal>. As you can see, <literal>Country @@ -469,10 +468,11 @@ properties persistent (see <literal>@MappedSuperclass</literal> for more informations).</para> - <para>You cannot use association annotations in an embeddable object - (ie no <literal>@*ToOne</literal> nor <literal>@*ToMany</literal>). - This is disallowed by the spec, and not yet supported in Hibernate - Annotations.</para> + <para>While not supported by the EJB3 specification, Hibernate + Annotations allows you to use association annotations in an embeddable + object (ie <literal>@*ToOne</literal> nor + <literal>@*ToMany</literal>). To override the association columns you + can use <literal>@AssociationOverride</literal>.</para> <para>If you want to have the same embeddable object type twice in the same entity, the column name defaulting will not work: at least one of @@ -706,6 +706,27 @@ <para>As you may have seen, <literal>@IdClass</literal> points to the corresponding primary key class.</para> + + <para>While not supported by the EJB3 specification, Hibernate allows + you to define associations inside a composite identifier. Simply use the + regular annotations for that</para> + + <programlisting>@Entity +@AssociationOverride( name="id.channel", joinColumns = @JoinColumn(name="chan_id") ) +public class TvMagazin { + @EmbeddedId public TvMagazinPk id; + @Temporal(TemporalType.TIME) Date time; +} + +@Embeddable +public class TvMagazinPk implements Serializable { + @ManyToOne + public Channel channel; + public String name; + @ManyToOne + public Presenter presenter; +} +</programlisting> </sect2> <sect2> @@ -789,11 +810,12 @@ <literal>@DiscriminatorValue</literal> annotation defines the value used to differentiate a class in the hierarchy. All of these attributes have sensible default values. The default name of the - discriminator column is <literal>TYPE</literal>, and (for Hibernate) - the default discriminator value is the fully qualified class name. + discriminator column is <literal>DTYPE</literal>. The default + discriminator value is the entity name (as defined in + <literal>@Entity.name</literal>) for DiscriminatorType.STRING. <classname>A320</classname> is a subclass; you only have to define discriminator value if you don't want to use the default value. The - strategy and the discriminator type is implicit.</para> + strategy and the discriminator type are implicit.</para> <para><literal>@Inheritance</literal> and <literal>@DiscriminatorColumn</literal> should only be defined at the @@ -903,18 +925,32 @@ public int getMetricAltitude() { return metricAltitude; } + + @ManyToOne + public PropulsionType getPropulsion() { + return metricAltitude; + } ... } @Entity @AttributeOverride( name="altitude", column = @Column(name="fld_altitude") ) +@AssociationOverride( name="propulsion", joinColumns = @JoinColumn(name="fld_propulsion_fk") ) public class Plane extends FlyingObject { ... }</programlisting> <para>The <literal>altitude</literal> property will be persisted in an <literal>fld_altitude</literal> column of table - <literal>Plane</literal>.</para> + <literal>Plane</literal> and the propulsion association will be + materialized in a <literal>fld_propulsion_fk</literal> foreign key + column.</para> + + <para>You can define <literal>@AttributeOverride</literal>(s) and + <literal>@AssociationOverride</literal>(s) on + <literal>@Entity</literal> classes, + <literal>@MappedSuperclass</literal> classes and properties pointing + to an <literal>@Embeddable</literal> object.</para> </sect3> </sect2> @@ -1026,7 +1062,7 @@ <programlisting> @Entity() public class Flight implements Serializable { - <emphasis role="bold">@ManyToOne</emphasis>( cascade = {CascadeType.CREATE, CascadeType.MERGE} ) + <emphasis role="bold">@ManyToOne</emphasis>( cascade = {CascadeType.PERSIST, CascadeType.MERGE} ) @JoinColumn(name="COMP_ID") public Company getCompany() { return company; @@ -1053,7 +1089,7 @@ <programlisting> @Entity() public class Flight implements Serializable { - @ManyToOne( cascade = {CascadeType.CREATE, CascadeType.MERGE}, <emphasis + @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE}, <emphasis role="bold">targetEntity=CompanyImpl.class</emphasis> ) @JoinColumn(name="COMP_ID") public Company getCompany() { @@ -1406,7 +1442,7 @@ public class Employer implements Serializable { @ManyToMany( targetEntity=org.hibernate.test.metadata.manytomany.Employee.class, - cascade={CascadeType.CREATE, CascadeType.MERGE} + cascade={CascadeType.PERSIST, CascadeType.MERGE} ) @JoinTable( name="EMPLOYER_EMPLOYEE", @@ -1424,7 +1460,7 @@ @Entity public class Employee implements Serializable { @ManyToMany( - cascade={CascadeType.CREATE, CascadeType.MERGE}, + cascade={CascadeType.PERSIST, CascadeType.MERGE}, mappedBy="employees" targetEntity=Employer.class ) @@ -1851,8 +1887,9 @@ <para>You can also map a native query (ie a plain SQL query). To achieve that, you need to describe the SQL resultset structure using - <literal>@SqlResultSetMapping</literal>. Like - <literal>@NamedQuery</literal>, a + <literal>@SqlResultSetMapping</literal> (or + <literal>@SqlResultSetMappings</literal> if you plan to define several + resulset mappings). Like <literal>@NamedQuery</literal>, a <literal>@SqlResultSetMapping</literal> can be defined at both package level or class level. However its scope is global to the application. As we will see, a <literal>resultSetMapping</literal> parameter is defined @@ -1870,14 +1907,14 @@ + "from Night night, Area area where night.area_id = area.id", <emphasis role="bold">resultSetMapping="joinMapping"</emphasis>) @SqlResultSetMapping(name="joinMapping", entities={ - @EntityResult(name="org.hibernate.test.annotations.query.Night", fields = { + @EntityResult(entityClass=org.hibernate.test.annotations.query.Night.class, fields = { @FieldResult(name="id", column="nid"), @FieldResult(name="duration", column="night_duration"), @FieldResult(name="date", column="night_date"), @FieldResult(name="area", column="area_id"), discriminatorColumn="disc" }), - @EntityResult(name="org.hibernate.test.annotations.query.Area", fields = { + @EntityResult(entityClass=org.hibernate.test.annotations.query.Area.class, fields = { @FieldResult(name="id", column="aid"), @FieldResult(name="name", column="name") }) @@ -1892,7 +1929,7 @@ see an implicit declaration of the property / column.</para> <programlisting>@Entity -<emphasis role="bold">@SqlResultSetMapping(name="implicit", entities=@EntityResult(name="org.hibernate.test.annotations.query.SpaceShip")) +<emphasis role="bold">@SqlResultSetMapping(name="implicit", entities=@EntityResult(entityClass=org.hibernate.test.annotations.query.SpaceShip.class)) @NamedNativeQuery(name="implicitSample", query="select * from SpaceShip", resultSetMapping="implicit")</emphasis> public class SpaceShip { private String name; @@ -1938,7 +1975,7 @@ <programlisting>@Entity @SqlResultSetMapping(name="compositekey", - entities=@EntityResult(name="org.hibernate.test.annotations.query.SpaceShip", + entities=@EntityResult(entityClass=org.hibernate.test.annotations.query.SpaceShip.class, fields = { @FieldResult(name="name", column = "name"), @FieldResult(name="model", column = "model"), @@ -1955,7 +1992,6 @@ query="select name, model, speed, lname as lastn, fname as firstn, length, width, length * width as surface from SpaceShip", resultSetMapping="compositekey") } ) -//we're missins @SqlREsultSetMappings so look at Captain public class SpaceShip { private String name; private String model; @@ -2147,17 +2183,24 @@ joined subclasses: use a SQL cascade delete on deletion instead of the regular Hibernate mechanism.</para> - <para><literal>@Table(name="tableName", indexes = { + <para><literal>@Table(appliesTo="tableName", indexes = { @Index(name="index1", columnNames={"column1", "column2"} ) } )</literal> - creates the defined indexes on the columns of table tableName. This can - be applied on the primary table or any secondary table. The - <literal>@Tables</literal> annotation allows your to apply indexes on - different tables. This annotation is expected where - <literal>@javax.persistence.Table</literal> or - <literal>@javax.persistence.SecondaryTable</literal>(s) occurs. - <literal>@org.hibernate.annotations.Table</literal> is a complement, not - a replacement to <literal>@javax.persistence.Table</literal></para> + creates the defined indexes on the columns of table + <literal>tableName</literal>. This can be applied on the primary table + or any secondary table. The <literal>@Tables</literal> annotation allows + your to apply indexes on different tables. This annotation is expected + where <literal>@javax.persistence.Table</literal> or + <literal>@javax.persistence.SecondaryTable</literal>(s) occurs. </para> + <note> + <para><literal>@org.hibernate.annotations.Table</literal> is a + complement, not a replacement to + <literal>@javax.persistence.Table</literal>. Especially, if you want + to change the default name of a table, you must use + <literal>@javax.persistence.Table</literal>, not + <literal>@org.hibernate.annotations.Table</literal>. </para> + </note> + <para><programlisting>@Entity @BatchSize(size=5) @org.hibernate.annotations.Entity( @@ -2418,7 +2461,7 @@ </sect2> <sect2> - <title>Association related annotations</title> + <title>Single Association related annotations</title> <para>By default, when Hibernate cannot resolve the association because the expected associated element is not in database (wrong id on the @@ -2438,6 +2481,21 @@ public Parent getParent() { ... } ... }</programlisting> + + <para>Sometimes you want to delegate to your database the deletion of + cascade when a given entity is deleted.</para> + + <programlisting>@Entity +public class Child { + ... + @ManyToOne + @OnDelete(action=OnDeleteAction.CASCADE) + public Parent getParent() { ... } + ... +}</programlisting> + + <para>In this case Hibernate generates a cascade delete constraint at + the database level.</para> </sect2> <sect2 id="entity-hibspec-collection" revision="2"> Modified: trunk/HibernateExt/metadata/doc/reference/en/modules/setup.xml =================================================================== --- trunk/HibernateExt/metadata/doc/reference/en/modules/setup.xml 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/doc/reference/en/modules/setup.xml 2006-03-16 22:19:13 UTC (rev 9641) @@ -12,13 +12,13 @@ </listitem> <listitem> - <para><emphasis>This preview release requires Hibernate 3.1.1 and + <para><emphasis>This preview release requires Hibernate 3.2alpha2 and above. Do not use this release of Hibernate Annotations with an older version of Hibernate 3.x!</emphasis></para> </listitem> <listitem> - <para>This release is known to work on Hibernate core 3.1.1</para> + <para>This release is known to work on Hibernate core 3.2alpha2</para> </listitem> <listitem> Modified: trunk/HibernateExt/metadata/doc/reference/en/modules/validator.xml =================================================================== --- trunk/HibernateExt/metadata/doc/reference/en/modules/validator.xml 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/doc/reference/en/modules/validator.xml 2006-03-16 22:19:13 UTC (rev 9641) @@ -52,8 +52,6 @@ covers most basic data checks. As we'll see later, you're not limited to them, you can in a minute write your own constraints.</para> - <para></para> - <table> <title>Built-in constraints</title> @@ -197,11 +195,24 @@ <entry>property (object)</entry> - <entry>Perform validation recursively on the associated - object</entry> + <entry>perform validation recursively on the associated object. + If the object is a Collection or an array, the elements are + validated recursively. If the object is a Map, the value + elements are validated recursively.</entry> <entry>none</entry> </row> + + <row> + <entry>@Email</entry> + + <entry>property (String)</entry> + + <entry>check whether the string is conform to the email address + specification</entry> + + <entry>none</entry> + </row> </tbody> </tgroup> </table> @@ -238,7 +249,7 @@ @Retention(RUNTIME) @Documented public @interface Capitalized { - CapitalizeType type default Capitalize.FIRST; + CapitalizeType type() default Capitalize.FIRST; String message() default "has incorrect capitalization"; }</programlisting> @@ -262,7 +273,7 @@ @Retention(RUNTIME) @Documented public @interface Capitalized { - CapitalizeType type default Capitalize.FIRST; + CapitalizeType type() default Capitalize.FIRST; String message() default "{validator.capitalized}"; } @@ -284,7 +295,7 @@ constraint at the database level (by implementing <literal>PersistentClassConstraint</literal>).</para> - <programlisting>public class LengthValidator + <programlisting>public class CapitalizedValidator implements Validator<Capitalized>, PropertyConstraint { private CapitalizeType type; @@ -510,14 +521,14 @@ individual issues.</para> <para><methodname>getBeanClass()</methodname> retrieves the failing bean - type </para> + type</para> <para><methodname>getBean()</methodname>retrieves the failing instance (if any ie not when using - <methodname>getPotentianInvalidValues()</methodname>) </para> + <methodname>getPotentianInvalidValues()</methodname>)</para> - <para><methodname>getValue()</methodname> retrieves the failing value - </para> + <para><methodname>getValue()</methodname> retrieves the failing + value</para> <para><methodname>getMessage()</methodname> retrieves the proper internationalized error message</para> Modified: trunk/HibernateExt/metadata/lib/ejb3-persistence.jar =================================================================== (Binary files differ) Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazin.java =================================================================== --- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazin.java 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazin.java 2006-03-16 22:19:13 UTC (rev 9641) @@ -6,11 +6,14 @@ import javax.persistence.EmbeddedId; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import javax.persistence.AssociationOverride; +import javax.persistence.JoinColumn; /** * @author Emmanuel Bernard */ @Entity +@AssociationOverride( name="id.channel", joinColumns = @JoinColumn(name="chan_id") ) public class TvMagazin { @EmbeddedId public TvMagazinPk id; @Temporal(TemporalType.TIME) Date time; Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazinPk.java =================================================================== --- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazinPk.java 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/TvMagazinPk.java 2006-03-16 22:19:13 UTC (rev 9641) @@ -4,7 +4,6 @@ import java.io.Serializable; import javax.persistence.Embeddable; import javax.persistence.ManyToOne; -import javax.persistence.JoinColumn; /** * @author Emmanuel Bernard @@ -12,7 +11,6 @@ @Embeddable public class TvMagazinPk implements Serializable { @ManyToOne - @JoinColumn(name="chan_id") public Channel channel; public String name; @ManyToOne Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java =================================================================== --- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java 2006-03-16 21:46:33 UTC (rev 9640) +++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java 2006-03-16 22:19:13 UTC (rev 9641) @@ -14,7 +14,8 @@ Transaction tx = s.beginTransaction(); Gene item = new Gene(); s.persist( item ); - tx.commit(); + s.flush(); + tx.rollback(); s.close(); } |
From: <hib...@li...> - 2006-03-16 21:46:56
|
Author: epbernard Date: 2006-03-16 16:46:33 -0500 (Thu, 16 Mar 2006) New Revision: 9640 Modified: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/QueryTest.java Log: better test Modified: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/QueryTest.java =================================================================== --- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/QueryTest.java 2006-03-16 21:45:03 UTC (rev 9639) +++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/QueryTest.java 2006-03-16 21:46:33 UTC (rev 9640) @@ -234,6 +234,37 @@ em.close(); } + public void testIsNull() throws Exception { + EntityManager em = factory.createEntityManager(); + em.getTransaction().begin(); + Distributor d1 = new Distributor(); + d1.setName( "Fnac" ); + Distributor d2 = new Distributor(); + d2.setName( "Darty" ); + Item item = new Item( "Mouse", null ); + Item item2 = new Item( "Mouse2", "dd" ); + item.getDistributors().add( d1 ); + item.getDistributors().add( d2 ); + em.persist( d1 ); + em.persist( d2 ); + em.persist( item ); + em.persist( item2 ); + em.flush(); + em.clear(); + Query q = em.createQuery( "select i from Item i where (i.descr is null and :descr is null) or i.descr = :descr"); + //Query q = em.createQuery( "select i from Item i where (i.descr is null and :descr is null) or (i.descr = :descr"); + q.setParameter( "descr", "dd" ); + List result = q.getResultList(); + assertEquals( 1, result.size() ); + q.setParameter( "descr", null ); + result = q.getResultList(); + assertEquals( 1, result.size() ); + //item = (Item) distinctResult.get( 0 ); + + em.getTransaction().rollback(); + em.close(); + } + public Class[] getAnnotatedClasses() { return new Class[]{ Item.class, |
From: <hib...@li...> - 2006-03-16 21:45:26
|
Author: epbernard Date: 2006-03-16 16:45:03 -0500 (Thu, 16 Mar 2006) New Revision: 9639 Modified: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java Log: better test Modified: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java =================================================================== --- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java 2006-03-16 16:20:52 UTC (rev 9638) +++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java 2006-03-16 21:45:03 UTC (rev 9639) @@ -172,6 +172,7 @@ //success } em.getTransaction().commit(); + assertFalse( em.isOpen() ); em = factory.createEntityManager( ); em.getTransaction().begin(); book = em.find( Book.class, book.id ); |
From: <hib...@li...> - 2006-03-16 16:21:02
|
Author: max...@jb... Date: 2006-03-16 11:20:52 -0500 (Thu, 16 Mar 2006) New Revision: 9638 Modified: trunk/Hibernate3/doc/reference/en/modules/query_sql.xml Log: more complete native sql documentation Modified: trunk/Hibernate3/doc/reference/en/modules/query_sql.xml =================================================================== --- trunk/Hibernate3/doc/reference/en/modules/query_sql.xml 2006-03-16 14:26:38 UTC (rev 9637) +++ trunk/Hibernate3/doc/reference/en/modules/query_sql.xml 2006-03-16 16:20:52 UTC (rev 9638) @@ -11,191 +11,385 @@ <para>Hibernate3 allows you to specify handwritten SQL (including stored procedures) for all create, update, delete, and load operations.</para> - <sect1 id="querysql-creating" revision="3"> + <sect1 id="querysql-creating" revision="4"> <title>Using a <literal>SQLQuery</literal></title> <para>Execution of native SQL queries is controlled via the <literal>SQLQuery</literal> interface, which is obtained by calling - <literal>Session.createSQLQuery()</literal>. In extremely simple cases, we - can use the following form:</para> + <literal>Session.createSQLQuery()</literal>. The following describes how + to use this API for querying.</para> - <programlisting><![CDATA[List cats = sess.createSQLQuery("select * from cats") - .addEntity(Cat.class) - .list();]]></programlisting> + <sect2> + <title>Scalar queries</title> - <para>This query specified:</para> + <para>The most basic SQL query is to get a list of scalars + (values).</para> - <itemizedlist> - <listitem> - <para>the SQL query string</para> - </listitem> + <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS").list(); +sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE FROM CATS").list(); +]]></programlisting> - <listitem> - <para>the entity returned by the query</para> - </listitem> - </itemizedlist> + <para>These will both return a List of Object arrays (Object[]) with + scalar values for each column in the CATS table. Hibernate will use + ResultSetMetadata to deduce the actual order and types of the returned + scalar values.</para> - <para>Here, the result set column names are assumed to be the same as the - column names specified in the mapping document. This can be problematic - for SQL queries which join multiple tables, since the same column names - may appear in more than one table. The following form is not vulnerable to - column name duplication:</para> + <para>To avoid the overhead of using + <literal>ResultSetMetadata</literal> or simply to be more explicit in + what is returned one can use <literal>addScalar()</literal>.</para> - <programlisting><![CDATA[List cats = sess.createSQLQuery("select {cat.*} from cats cat") - .addEntity("cat", Cat.class) - .list();]]></programlisting> + <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS") + .addScalar("ID", Hibernate.LONG) + .addScalar("NAME", Hibernate.STRING) + .addScalar("BIRTHDATE", Hibernate.DATE) +]]></programlisting> - <para>This query specified:</para> + <para>This query specified:</para> - <itemizedlist> - <listitem> - <para>the SQL query string, with a placeholder for Hibernate to inject - the column aliases</para> - </listitem> + <itemizedlist> + <listitem> + <para>the SQL query string</para> + </listitem> - <listitem> - <para>the entity returned by the query, and its SQL table alias</para> - </listitem> - </itemizedlist> + <listitem> + <para>the columns and types to return</para> + </listitem> + </itemizedlist> - <para>The <literal>addEntity()</literal> method associates the SQL table - alias with the returned entity class, and determines the shape of the - query result set.</para> + <para>This will still return Object arrays, but now it will not use + <literal>ResultSetMetdata</literal> but will instead explicitly get the + ID, NAME and BIRTHDATE column as respectively a Long, String and a Short + from the underlying resultset. This also means that only these three + columns will be returned, even though the query is using + <literal>*</literal> and could return more than the three listed + columns.</para> - <para>The <literal>addJoin()</literal> method may be used to load - associations to other entities and collections.</para> + <para>It is possible to leave out the type information for all or some + of the scalars.</para> - <programlisting><![CDATA[List cats = sess.createSQLQuery( - "select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id" - ) - .addEntity("cat", Cat.class) - .addJoin("kitten", "cat.kittens") - .list();]]></programlisting> + <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS") + .addScalar("ID", Hibernate.LONG) + .addScalar("NAME") + .addScalar("BIRTHDATE") +]]></programlisting> - <para>A native SQL query might return a simple scalar value or a - combination of scalars and entities.</para> + <para>This is essentially the same query as before, but now + <literal>ResultSetMetaData</literal> is used to decide the type of NAME + and BIRTHDATE where as the type of ID is explicitly specified.</para> - <programlisting><![CDATA[Double max = (Double) sess.createSQLQuery("select max(cat.weight) as maxWeight from cats cat") - .addScalar("maxWeight", Hibernate.DOUBLE); - .uniqueResult();]]></programlisting> + <para>How the java.sql.Types returned from ResultSetMetaData is mapped + to Hibernate types is controlled by the Dialect. If a specific type is + not mapped or does not result in the expected type it is possible to + customize it via calls to <literal>registerHibernateType</literal> in + the Dialect.</para> + </sect2> - <para>You can alternatively describe the resultset mapping informations in - your hbm files and use them for your queries</para> + <sect2> + <title>Entity queries</title> - <programlisting><![CDATA[List cats = sess.createSQLQuery( - "select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id" - ) - .setResultSetMapping("catAndKitten") - .list();]]></programlisting> - </sect1> + <para>The above queries were all about returning scalar values, + basically returning the "raw" values from the resultset. The following + shows how to get entity objects from a native sql query via + <literal>addEntity()</literal>.</para> - <sect1 id="querysql-aliasreferences"> - <title>Alias and property references</title> + <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS").addEntity(Cat.class); +sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE FROM CATS").addEntity(Cat.class); +]]></programlisting> - <para>The <literal>{cat.*}</literal> notation used above is a shorthand - for "all properties". Alternatively, you may list the columns explicity, - but even this case we let Hibernate inject the SQL column aliases for each - property. The placeholder for a column alias is just the property name - qualified by the table alias. In the following example, we retrieve - <literal>Cat</literal>s from a different table - (<literal>cat_log</literal>) to the one declared in the mapping metadata. - Notice that we may even use the property aliases in the where clause if we - like.</para> + <para>This query specified:</para> - <para>The <literal>{}</literal>-syntax is <emphasis>not</emphasis> - required for named queries. See <xref - linkend="querysql-namedqueries" /></para> + <itemizedlist> + <listitem> + <para>the SQL query string</para> + </listitem> - <programlisting><![CDATA[String sql = "select cat.originalId as {cat.id}, " + - "cat.mateid as {cat.mate}, cat.sex as {cat.sex}, " + - "cat.weight*10 as {cat.weight}, cat.name as {cat.name} " + - "from cat_log cat where {cat.mate} = :catId" + <listitem> + <para>the entity returned by the query</para> + </listitem> + </itemizedlist> + <para>Assuming that Cat is mapped as a class with the columns ID, NAME + and BIRTHDATE the above queries will both return a List where each + element is a Cat entity.</para> + + <para>If the entity is mapped with a <literal>many-to-one</literal> to + another entity it is required to also return this when performing the + native query, otherwise a database specific "column not found" error + will occur. The additional columns will automatically be returned when + using the * notation, but we prefer to be explicit as in the following + example for a <literal>many-to-one</literal> to a + <literal>Dog</literal>:</para> + + <programlisting><![CDATA[sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, DOG_ID FROM CATS").addEntity(Cat.class); +]]></programlisting> + + <para>This will allow cat.getDog() to function properly.</para> + </sect2> + + <sect2> + <title>Handling associations and collections</title> + + <para>It is possible to eagerly join in the <literal>Dog</literal> to + avoid the possible extra roundtrip for initializing the proxy. This is + done via the <literal>addJoin()</literal> method, which allows you to + join in an association or collection.</para> + + <programlisting><![CDATA[sess.createSQLQuery("SELECT c.ID, NAME, BIRTHDATE, DOG_ID, D_ID, D_NAME FROM CATS c, DOGS d WHERE c.DOG_ID = d.D_ID") + .addEntity("cat", Cat.class) + .addJoin("cat.dog"); +]]></programlisting> + + <para>In this example the returned <literal>Cat</literal>'s will have + their <literal>dog</literal> property fully initialized without any + extra roundtrip to the database. Notice that we added a alias name + ("cat") to be able to specify the target property path of the join. It + is possible to do the same eager joining for collections, e.g. if the + <literal>Cat</literal> had a one-to-many to <literal>Dog</literal> + instead.</para> + + <programlisting><![CDATA[sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, D_ID, D_NAME, CAT_ID FROM CATS c, DOGS d WHERE c.ID = d.CAT_ID") + .addEntity("cat", Cat.class) + .addJoin("cat.dogs"); +]]></programlisting> + + <p>At this stage we are reaching the limits of what is possible with + native queries without starting to enhance the sql queries to make them + usable in Hibernate; the problems starts to arise when returning + multiple entities of the same type or when the default alias/column + names are not enough.</p> + </sect2> + + <sect2> + <title>Returning multiple entities</title> + + <para>Until now the result set column names are assumed to be the same + as the column names specified in the mapping document. This can be + problematic for SQL queries which join multiple tables, since the same + column names may appear in more than one table.</para> + + <para>Column alias injection is needed in the following query (which + most likely will fail):</para> + + <programlisting><![CDATA[sess.createSQLQuery("SELECT c.*, m.* FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID") + .addEntity("cat", Cat.class) + .addEntity("mother", Cat.class) +]]></programlisting> + + <para>The intention for this query is to return two Cat instances per + row, a cat and its mother. This will fail since there is a conflict of + names since they are mapped to the same column names and on some + databases the returned column aliases will most likely be on the form + "c.ID", "c.NAME", etc. which are not equal to the columns specificed in + the mappings ("ID" and "NAME").</para> + + <para>The following form is not vulnerable to column name + duplication:</para> + + <programlisting><![CDATA[sess.createSQLQuery("SELECT {cat.*}, {mother.*} FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID") + .addEntity("cat", Cat.class) + .addEntity("mother", Cat.class) +]]></programlisting> + + <para>This query specified:</para> + + <itemizedlist> + <listitem> + <para>the SQL query string, with placeholders for Hibernate to + inject column aliases</para> + </listitem> + + <listitem> + <para>the entities returned by the query</para> + </listitem> + </itemizedlist> + + <para>The {cat.*} and {mother.*} notation used above is a shorthand for + "all properties". Alternatively, you may list the columns explicity, but + even in this case we let Hibernate inject the SQL column aliases for + each property. The placeholder for a column alias is just the property + name qualified by the table alias. In the following example, we retrieve + Cats and their mothers from a different table (cat_log) to the one + declared in the mapping metadata. Notice that we may even use the + property aliases in the where clause if we like.</para> + + <programlisting><![CDATA[String sql = "SELECT ID as {c.id}, NAME as {c.name}, " + + "BIRTHDATE as {c.birthDate}, MOTHER_ID as {c.mother}, {mother.*} " + + "FROM CAT_LOG c, CAT_LOG m WHERE {c.mother} = c.ID"; + List loggedCats = sess.createSQLQuery(sql) - .addEntity("cat", Cat.class) - .setLong("catId", catId) - .list();]]></programlisting> + .addEntity("cat", Cat.class) + .addEntity("mother", Cat.class).list() +]]></programlisting> - <para><emphasis>Note:</emphasis> if you list each property explicitly, you - must include all properties of the class <emphasis>and its - subclasses</emphasis>!</para> + <sect3 id="querysql-aliasreferences" revision="2"> + <title>Alias and property references</title> - <para>The following table shows the different possibilities of using the - alias injection. Note: the alias names in the result are examples, each - alias will have a unique and probably different name when used.</para> + <para>For most cases the above alias injection is needed, but for + queries relating to more complex mappings like composite properties, + inheritance discriminators, collections etc. there are some specific + aliases to use to allow Hibernate to inject the proper aliases.</para> - <table frame="topbot" id="aliasinjection-summary"> - <title>Alias injection names</title> + <para>The following table shows the different possibilities of using + the alias injection. Note: the alias names in the result are examples, + each alias will have a unique and probably different name when + used.</para> - <tgroup cols="4"> - <colspec colwidth="1*" /> + <table frame="topbot" id="aliasinjection-summary"> + <title>Alias injection names</title> - <colspec colwidth="1*" /> + <tgroup cols="3"> + <colspec colwidth="1*" /> - <colspec colwidth="2.5*" /> + <colspec colwidth="1*" /> - <thead> - <row> - <entry>Description</entry> - <entry>Syntax</entry> - <entry>Example</entry> - </row> - </thead> - <tbody> - <row> - <entry>A simple property</entry> - <entry><literal>{[aliasname].[propertyname]</literal></entry> - <entry><literal>A_NAME as {item.name}</literal></entry> - </row> - <row> - <entry>A composite property</entry> - <entry><literal>{[aliasname].[componentname].[propertyname]}</literal></entry> - <entry><literal>CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}</literal></entry> - </row> - <row> - <entry>Discriminator of an entity</entry> - <entry><literal>{[aliasname].class}</literal></entry> - <entry><literal>DISC as {item.class}</literal></entry> - </row> - <row> - <entry>All properties of an entity</entry> - <entry><literal>{[aliasname].*}</literal></entry> - <entry><literal>{item.*}</literal></entry> - </row> - <row> - <entry>A collection key</entry> - <entry><literal>{[aliasname].key}</literal></entry> - <entry><literal>ORGID as {coll.key}</literal></entry> - </row> - <row> - <entry>The id of an collection</entry> - <entry><literal>{[aliasname].id}</literal></entry> - <entry><literal>EMPID as {coll.id}</literal></entry> - </row> - <row> - <entry>The element of an collection</entry> - <entry><literal>{[aliasname].element}</literal></entry> - <entry><literal>XID as {coll.element}</literal></entry> - <entry></entry> - </row> - <row> - <entry>Property of the element in the collection</entry> - <entry><literal>{[aliasname].element.[propertyname]}</literal></entry> - <entry><literal>NAME as {coll.element.name}</literal></entry> - </row> - <row> - <entry>All properties of the element in the collection</entry> - <entry><literal>{[aliasname].element.*}</literal></entry> - <entry><literal>{coll.element.*}</literal></entry> - </row> - <row> - <entry>All properties of the the collection</entry> - <entry><literal>{[aliasname].*}</literal></entry> - <entry><literal>{coll.*}</literal></entry> - </row> - </tbody> - </tgroup> - </table> + <colspec colwidth="2.5*" /> + + <thead> + <row> + <entry>Description</entry> + + <entry>Syntax</entry> + + <entry>Example</entry> + </row> + </thead> + + <tbody> + <row> + <entry>A simple property</entry> + + <entry><literal>{[aliasname].[propertyname]</literal></entry> + + <entry><literal>A_NAME as {item.name}</literal></entry> + </row> + + <row> + <entry>A composite property</entry> + + <entry><literal>{[aliasname].[componentname].[propertyname]}</literal></entry> + + <entry><literal>CURRENCY as {item.amount.currency}, VALUE as + {item.amount.value}</literal></entry> + </row> + + <row> + <entry>Discriminator of an entity</entry> + + <entry><literal>{[aliasname].class}</literal></entry> + + <entry><literal>DISC as {item.class}</literal></entry> + </row> + + <row> + <entry>All properties of an entity</entry> + + <entry><literal>{[aliasname].*}</literal></entry> + + <entry><literal>{item.*}</literal></entry> + </row> + + <row> + <entry>A collection key</entry> + + <entry><literal>{[aliasname].key}</literal></entry> + + <entry><literal>ORGID as {coll.key}</literal></entry> + </row> + + <row> + <entry>The id of an collection</entry> + + <entry><literal>{[aliasname].id}</literal></entry> + + <entry><literal>EMPID as {coll.id}</literal></entry> + </row> + + <row> + <entry>The element of an collection</entry> + + <entry><literal>{[aliasname].element}</literal></entry> + + <entry><literal>XID as {coll.element}</literal></entry> + </row> + + <row> + <entry>roperty of the element in the collection</entry> + + <entry><literal>{[aliasname].element.[propertyname]}</literal></entry> + + <entry><literal>NAME as {coll.element.name}</literal></entry> + </row> + + <row> + <entry>All properties of the element in the collection</entry> + + <entry><literal>{[aliasname].element.*}</literal></entry> + + <entry><literal>{coll.element.*}</literal></entry> + </row> + + <row> + <entry>All properties of the the collection</entry> + + <entry><literal>{[aliasname].*}</literal></entry> + + <entry><literal>{coll.*}</literal></entry> + </row> + </tbody> + </tgroup> + </table> + </sect3> + </sect2> + + <sect2> + <title>Returning non-managed entities</title> + + <para>It is possible to apply a ResultTransformer to native sql queries. Allowing it to e.g. return non-managed entities.</para> + + <programlisting><![CDATA[sess.createSQLQuery("SELECT NAME, BIRTHDATE FROM CATS") + .setResultTransformer(Transformers.aliasToBean(CatDTO.class))]]></programlisting> + + <para>This query specified:</para> + + <itemizedlist> + <listitem> + <para>the SQL query string</para> + </listitem> + + <listitem> + <para>a result transformer</para> + </listitem> + </itemizedlist> + + <para> + The above query will return a list of <literal>CatDTO</literal> which has been instantiated and injected the values of NAME and BIRTHNAME into its corresponding + properties or fields. + </para> + </sect2> + + <sect2> + <title>Handling inheritance</title> + + <para>Native sql queries which query for entities that is mapped as part + of an inheritance must include all properties for the baseclass and all + it subclasses.</para> + </sect2> + + <sect2> + <title>Parameters</title> + + <para>Native sql queries support positional as well as named + parameters:</para> + + <programlisting><![CDATA[Query query = sess.createSQLQuery("SELECT * FROM CATS WHERE NAME like ?").addEntity(Cat.class); +List pusList = query.setString(0, "Pus%").list(); + +query = sess.createSQLQuery("SELECT * FROM CATS WHERE NAME like :name").addEntity(Cat.class); +List pusList = query.setString("name", "Pus%").list(); ]]></programlisting> + </sect2> + + + </sect1> <sect1 id="querysql-namedqueries" revision="3"> @@ -277,6 +471,15 @@ WHERE person.NAME LIKE :namePattern </sql-query>]]></programlisting> + <para>You can alternatively use the resultset mapping information in your + hbm files directly in java code.</para> + + <programlisting><![CDATA[List cats = sess.createSQLQuery( + "select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id" + ) + .setResultSetMapping("catAndKitten") + .list();]]></programlisting> + <sect2 id="propertyresults"> <title>Using return-property to explicitly specify column/alias names</title> @@ -325,22 +528,19 @@ <literal>{}</literal>-syntax for injection. Allowing users to choose how they want to refer column and properties.</para> - <para> - If your mapping has a discriminator you must use - <literal><return-discriminator></literal> to specify the - discriminator column. - </para> - + <para>If your mapping has a discriminator you must use + <literal><return-discriminator></literal> to specify the + discriminator column.</para> </sect2> <sect2 id="sp_query" revision="1"> <title>Using stored procedures for querying</title> <para>Hibernate 3 introduces support for queries via stored procedures - and functions. Most of the following documentation is equivalent for both. - The stored procedure/function must return a resultset as the first out-parameter - to be able to work with Hibernate. An example of such a stored function - in Oracle 9 and higher is as follows:</para> + and functions. Most of the following documentation is equivalent for + both. The stored procedure/function must return a resultset as the first + out-parameter to be able to work with Hibernate. An example of such a + stored function in Oracle 9 and higher is as follows:</para> <programlisting><![CDATA[CREATE OR REPLACE FUNCTION selectAllEmployments RETURN SYS_REFCURSOR @@ -381,11 +581,11 @@ <sect3 id="querysql-limits-storedprocedures" revision="1"> <title>Rules/limitations for using stored procedures</title> - <para>To use stored procedures with Hibernate the procedures/functions have to - follow some rules. If they do not follow those rules they are not - usable with Hibernate. If you still want to use these procedures you - have to execute them via <literal>session.connection()</literal>. The - rules are different for each database, since database vendors have + <para>To use stored procedures with Hibernate the procedures/functions + have to follow some rules. If they do not follow those rules they are + not usable with Hibernate. If you still want to use these procedures + you have to execute them via <literal>session.connection()</literal>. + The rules are different for each database, since database vendors have different stored procedure semantics/syntax.</para> <para>Stored procedure queries can't be paged with @@ -393,18 +593,19 @@ <para>Recommended call form is standard SQL92: <literal>{ ? = call functionName(<parameters>) }</literal> or <literal>{ ? = call - procedureName(<parameters>}</literal>. Native call syntax is - not supported.</para> + procedureName(<parameters>}</literal>. Native call syntax is not + supported.</para> <para>For Oracle the following rules apply:</para> <itemizedlist spacing="compact"> <listitem> <para>A function must return a result set. The first parameter of - a procedure must be an <literal>OUT</literal> that returns a result - set. This is done by using a <literal>SYS_REFCURSOR</literal> type - in Oracle 9 or 10. In Oracle you need to define a - <literal>REF CURSOR</literal> type, see Oracle literature.</para> + a procedure must be an <literal>OUT</literal> that returns a + result set. This is done by using a + <literal>SYS_REFCURSOR</literal> type in Oracle 9 or 10. In Oracle + you need to define a <literal>REF CURSOR</literal> type, see + Oracle literature.</para> </listitem> </itemizedlist> @@ -554,5 +755,4 @@ WHERE ID=? </sql-query>]]></programlisting> </sect1> - </chapter> \ No newline at end of file |
From: <hib...@li...> - 2006-03-16 14:26:52
|
Author: max...@jb... Date: 2006-03-16 09:26:38 -0500 (Thu, 16 Mar 2006) New Revision: 9637 Added: trunk/Hibernate3/src/org/hibernate/transform/AliasToBeanConstructorResultTransformer.java trunk/Hibernate3/src/org/hibernate/transform/ToListResultTransformer.java trunk/Hibernate3/src/org/hibernate/transform/Transformers.java Log: HHH-38 Add setResultClass or similar to Criteria and HQL HHH-332 Add ResultTransformer support for HQL HHH-587 Add ResultTransformer for all query methods (HQL, Criteria & SQL) Added: trunk/Hibernate3/src/org/hibernate/transform/AliasToBeanConstructorResultTransformer.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/transform/AliasToBeanConstructorResultTransformer.java 2006-03-16 14:14:48 UTC (rev 9636) +++ trunk/Hibernate3/src/org/hibernate/transform/AliasToBeanConstructorResultTransformer.java 2006-03-16 14:26:38 UTC (rev 9637) @@ -0,0 +1,33 @@ +package org.hibernate.transform; + +import java.lang.reflect.Constructor; +import java.util.List; + +import org.hibernate.QueryException; + +public class AliasToBeanConstructorResultTransformer implements ResultTransformer { + + private Constructor constructor; + + public AliasToBeanConstructorResultTransformer(Constructor constructor) { + this.constructor = constructor; + } + + public Object transformTuple(Object[] tuple, String[] aliases) { + try { + return constructor.newInstance( tuple ); + } + catch ( Exception e ) { + throw new QueryException( + "could not instantiate: " + + constructor.getDeclaringClass().getName(), + e ); + } + } + + public List transformList(List collection) { + return collection; + } + + +} Added: trunk/Hibernate3/src/org/hibernate/transform/ToListResultTransformer.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/transform/ToListResultTransformer.java 2006-03-16 14:14:48 UTC (rev 9636) +++ trunk/Hibernate3/src/org/hibernate/transform/ToListResultTransformer.java 2006-03-16 14:26:38 UTC (rev 9637) @@ -0,0 +1,20 @@ +package org.hibernate.transform; + +import java.util.Arrays; +import java.util.List; + +public class ToListResultTransformer implements ResultTransformer { + + public static final ResultTransformer INSTANCE = new ToListResultTransformer(); + + private ToListResultTransformer() {} + + public Object transformTuple(Object[] tuple, String[] aliases) { + return Arrays.asList(tuple); + } + + public List transformList(List collection) { + return collection; + } + +} Added: trunk/Hibernate3/src/org/hibernate/transform/Transformers.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/transform/Transformers.java 2006-03-16 14:14:48 UTC (rev 9636) +++ trunk/Hibernate3/src/org/hibernate/transform/Transformers.java 2006-03-16 14:26:38 UTC (rev 9637) @@ -0,0 +1,25 @@ +package org.hibernate.transform; + +final public class Transformers { + + private Transformers() {} + + /** + * Each row of results is a <tt>Map</tt> from alias to values/entities + */ + public static final ResultTransformer ALIAS_TO_ENTITY_MAP = new AliasToEntityMapResultTransformer(); + + /** + * Each row of results is a <tt>List</tt> + */ + public static final ResultTransformer TO_LIST = ToListResultTransformer.INSTANCE; + + /** + * Creates a resulttransformer that will inject aliased values into + * instances of Class via property methods or fields. + */ + public static ResultTransformer aliasToBean(Class target) { + return new AliasToBeanResultTransformer(target); + } + +} |