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: <tu...@us...> - 2006-02-25 12:39:28
|
Update of /cvsroot/hibernate/CaveatEmptor/HiA-SE/src/etc/conf/conf/META-INF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29085/HiA-SE/src/etc/conf/conf/META-INF Log Message: Directory /cvsroot/hibernate/CaveatEmptor/HiA-SE/src/etc/conf/conf/META-INF added to the repository |
From: <tu...@us...> - 2006-02-25 12:39:22
|
Update of /cvsroot/hibernate/CaveatEmptor/HiA-SE/src/etc/conf/conf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29051/HiA-SE/src/etc/conf/conf Log Message: Directory /cvsroot/hibernate/CaveatEmptor/HiA-SE/src/etc/conf/conf added to the repository |
From: <tu...@us...> - 2006-02-25 12:38:49
|
Update of /cvsroot/hibernate/CaveatEmptor/HiA-SE/src/etc/conf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28699/HiA-SE/src/etc/conf Log Message: Directory /cvsroot/hibernate/CaveatEmptor/HiA-SE/src/etc/conf added to the repository |
From: <ste...@us...> - 2006-02-24 22:12:20
|
Update of /cvsroot/hibernate/Hibernate3/src/org/hibernate/engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23075/src/org/hibernate/engine Modified Files: JoinSequence.java Log Message: HHH-1520 : with clause improvements Index: JoinSequence.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/engine/JoinSequence.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- JoinSequence.java 15 Jun 2005 17:18:14 -0000 1.17 +++ JoinSequence.java 24 Feb 2006 22:12:13 -0000 1.18 @@ -125,10 +125,14 @@ } public JoinFragment toJoinFragment(Map enabledFilters, boolean includeExtraJoins) throws MappingException { - return toJoinFragment( enabledFilters, includeExtraJoins, null ); + return toJoinFragment( enabledFilters, includeExtraJoins, null, null ); } - public JoinFragment toJoinFragment(Map enabledFilters, boolean includeExtraJoins, String extraOnClause) throws MappingException { + public JoinFragment toJoinFragment( + Map enabledFilters, + boolean includeExtraJoins, + String withClauseFragment, + String withClauseJoinAlias) throws MappingException { QueryJoinFragment joinFragment = new QueryJoinFragment( factory.getDialect(), useThetaStyle ); if ( rootJoinable != null ) { joinFragment.addCrossJoin( rootJoinable.getTableName(), rootAlias ); @@ -165,8 +169,10 @@ else { condition = on; } - if ( extraOnClause != null ) { - condition += " and " + extraOnClause; + if ( withClauseFragment != null ) { + if ( join.getAlias().equals( withClauseJoinAlias ) ) { + condition += " and " + withClauseFragment; + } } joinFragment.addJoin( join.getJoinable().getTableName(), |
From: <ste...@us...> - 2006-02-24 22:11:56
|
Update of /cvsroot/hibernate/Hibernate3/src/org/hibernate/hql/ast In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22750/src/org/hibernate/hql/ast Modified Files: HqlSqlWalker.java Log Message: HHH-1520 : with clause improvements Index: HqlSqlWalker.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/hql/ast/HqlSqlWalker.java,v retrieving revision 1.117 retrieving revision 1.118 diff -u -d -r1.117 -r1.118 --- HqlSqlWalker.java 16 Feb 2006 19:23:22 -0000 1.117 +++ HqlSqlWalker.java 24 Feb 2006 22:11:53 -0000 1.118 @@ -14,6 +14,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.QueryException; +import org.hibernate.HibernateException; import org.hibernate.engine.JoinSequence; import org.hibernate.engine.ParameterBinder; import org.hibernate.engine.SessionFactoryImplementor; @@ -44,6 +45,8 @@ import org.hibernate.hql.ast.tree.UpdateStatement; import org.hibernate.hql.ast.tree.Node; import org.hibernate.hql.ast.tree.OperatorNode; +import org.hibernate.hql.ast.tree.BinaryLogicOperatorNode; +import org.hibernate.hql.ast.tree.InLogicOperatorNode; import org.hibernate.hql.ast.util.ASTPrinter; import org.hibernate.hql.ast.util.ASTUtil; import org.hibernate.hql.ast.util.AliasGenerator; @@ -51,6 +54,7 @@ import org.hibernate.hql.ast.util.LiteralProcessor; import org.hibernate.hql.ast.util.SessionFactoryHelper; import org.hibernate.hql.ast.util.SyntheticAndFactory; +import org.hibernate.hql.ast.util.NodeTraverser; import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.PostInsertIdentifierGenerator; import org.hibernate.id.SequenceGenerator; @@ -334,15 +338,80 @@ try { withClause( hqlWithNode ); AST hqlSqlWithNode = returnAST; + if ( log.isDebugEnabled() ) { + log.debug( "handleWithFragment() : " + getASTPrinter().showAsString( hqlSqlWithNode, "-- with clause --" ) ); + } + WithClauseVisitor visitor = new WithClauseVisitor(); + NodeTraverser traverser = new NodeTraverser( visitor ); + traverser.traverseDepthFirst( hqlSqlWithNode ); + FromElement referencedFromElement = visitor.getReferencedFromElement(); + if ( referencedFromElement != fromElement ) { + throw new SemanticException( "with-clause expressions did not reference from-clause element to which the with-clause was associated" ); + } SqlGenerator sql = new SqlGenerator( getSessionFactoryHelper().getFactory() ); sql.whereExpr( hqlSqlWithNode.getFirstChild() ); - fromElement.setAdHocOnClauseFragment( "(" + sql.getSQL() + ")" ); + fromElement.setWithClauseFragment( visitor.getJoinAlias(), "(" + sql.getSQL() + ")" ); - } catch ( Exception e) { + } + catch( SemanticException e ) { + throw e; + } + catch ( Exception e) { throw new SemanticException( e.getMessage() ); } } + private static class WithClauseVisitor implements NodeTraverser.VisitationStrategy { + private FromElement referencedFromElement; + private String joinAlias; + + public void visit(AST node) { + // todo : currently expects that the individual with expressions apply to the same sql table join. + // This may not be the case for joined-subclass where the property values + // might be coming from different tables in the joined hierarchy. At some + // point we should expand this to support that capability. However, that has + // some difficulties: + // 1) the biggest is how to handle ORs when the individual comparisons are + // linked to different sql joins. + // 2) here we would need to track each comparison individually, along with + // the join alias to which it applies and then pass that information + // back to the FromElement so it can pass it along to the JoinSequence + + if ( node instanceof DotNode ) { + DotNode dotNode = ( DotNode ) node; + FromElement fromElement = dotNode.getFromElement(); + if ( referencedFromElement != null ) { + if ( fromElement != referencedFromElement ) { + throw new HibernateException( "with-clause referenced two different from-clause elements" ); + } + } + else { + referencedFromElement = fromElement; + joinAlias = extractAppliedAlias( dotNode ); + // todo : temporary + // needed because currently persister is the one that + // creates and renders the join fragments for inheritence + // hierarchies... + if ( !joinAlias.equals( referencedFromElement.getTableAlias() ) ) { + throw new HibernateException( "with clause can only reference columns in the driving table" ); + } + } + } + } + + private String extractAppliedAlias(DotNode dotNode) { + return dotNode.getText().substring( 0, dotNode.getText().indexOf( '.' ) ); + } + + public FromElement getReferencedFromElement() { + return referencedFromElement; + } + + public String getJoinAlias() { + return joinAlias; + } + } + /** * Sets the current 'FROM' context. * |
From: <ste...@us...> - 2006-02-24 22:11:56
|
Update of /cvsroot/hibernate/Hibernate3/src/org/hibernate/hql/ast/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22750/src/org/hibernate/hql/ast/util Modified Files: ASTUtil.java JoinProcessor.java Added Files: NodeTraverser.java Log Message: HHH-1520 : with clause improvements --- NEW FILE: NodeTraverser.java --- package org.hibernate.hql.ast.util; import antlr.collections.AST; /** * A visitor for traversing an AST tree. * * @author Steve Ebersole */ public class NodeTraverser { public static interface VisitationStrategy { public void visit(AST node); } private final VisitationStrategy strategy; public NodeTraverser(VisitationStrategy strategy) { this.strategy = strategy; } /** * Traverse the AST tree depth first. * <p/> * Note that the AST passed in is not visited itself. Visitation starts * with its children. * * @param ast */ public void traverseDepthFirst(AST ast) { if ( ast == null ) { throw new IllegalArgumentException( "node to traverse cannot be null!" ); } visitDepthFirst( ast.getFirstChild() ); } private void visitDepthFirst(AST ast) { if ( ast == null ) { return; } strategy.visit( ast ); visitDepthFirst( ast.getFirstChild() ); visitDepthFirst( ast.getNextSibling() ); } } Index: ASTUtil.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/hql/ast/util/ASTUtil.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ASTUtil.java 12 Jul 2005 20:27:17 -0000 1.1 +++ ASTUtil.java 24 Feb 2006 22:11:53 -0000 1.2 @@ -112,8 +112,9 @@ */ public static AST findTypeInChildren(AST parent, int type) { AST n = parent.getFirstChild(); - while ( n != null && n.getType() != type ) + while ( n != null && n.getType() != type ) { n = n.getNextSibling(); + } return n; } @@ -219,8 +220,9 @@ } public static void appendSibling(AST n, AST s) { - while ( n.getNextSibling() != null ) + while ( n.getNextSibling() != null ) { n = n.getNextSibling(); + } n.setNextSibling( s ); } @@ -273,9 +275,35 @@ } public static List collectChildren(AST root, FilterPredicate predicate) { - List children = new ArrayList(); - collectChildren( children, root, predicate ); - return children; +// List children = new ArrayList(); +// collectChildren( children, root, predicate ); +// return children; + return new CollectingNodeVisitor( predicate ).collect( root ); + } + + private static class CollectingNodeVisitor implements NodeTraverser.VisitationStrategy { + private final FilterPredicate predicate; + private final List collectedNodes = new ArrayList(); + + public CollectingNodeVisitor(FilterPredicate predicate) { + this.predicate = predicate; + } + + public void visit(AST node) { + if ( predicate == null || !predicate.exclude( node ) ) { + collectedNodes.add( node ); + } + } + + public List getCollectedNodes() { + return collectedNodes; + } + + public List collect(AST root) { + NodeTraverser traverser = new NodeTraverser( this ); + traverser.traverseDepthFirst( root ); + return collectedNodes; + } } private static void collectChildren(List children, AST root, FilterPredicate predicate) { Index: JoinProcessor.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/hql/ast/util/JoinProcessor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- JoinProcessor.java 6 Oct 2005 20:10:46 -0000 1.4 +++ JoinProcessor.java 24 Feb 2006 22:11:53 -0000 1.5 @@ -107,7 +107,8 @@ JoinFragment joinFragment = join.toJoinFragment( inSubquery ? Collections.EMPTY_MAP : queryTranslatorImpl.getEnabledFilters(), fromElement.useFromFragment(), - fromElement.getAdHocOnClauseFragment() + fromElement.getWithClauseFragment(), + fromElement.getWithClauseJoinAlias() ); String frag = joinFragment.toFromFragmentString(); |
From: <ste...@us...> - 2006-02-24 22:11:56
|
Update of /cvsroot/hibernate/Hibernate3/src/org/hibernate/hql/ast/tree In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22750/src/org/hibernate/hql/ast/tree Modified Files: FromElement.java Log Message: HHH-1520 : with clause improvements Index: FromElement.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/hql/ast/tree/FromElement.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FromElement.java 13 Jan 2006 03:10:21 -0000 1.4 +++ FromElement.java 24 Feb 2006 22:11:53 -0000 1.5 @@ -58,7 +58,8 @@ private boolean useWhereFragment = true; private List destinations = new LinkedList(); private boolean manyToMany = false; - private String adHocOnClauseFragment = null; + private String withClauseFragment = null; + private String withClauseJoinAlias; public FromElement() { } @@ -478,12 +479,17 @@ isAllPropertyFetch = fetch; } - public String getAdHocOnClauseFragment() { - return adHocOnClauseFragment; + public String getWithClauseFragment() { + return withClauseFragment; } - public void setAdHocOnClauseFragment(String adHocOnClauseFragment) { - this.adHocOnClauseFragment = adHocOnClauseFragment; + public String getWithClauseJoinAlias() { + return withClauseJoinAlias; + } + + public void setWithClauseFragment(String withClauseJoinAlias, String withClauseFragment) { + this.withClauseJoinAlias = withClauseJoinAlias; + this.withClauseFragment = withClauseFragment; } public boolean hasCacheablePersister() { |
From: <ste...@us...> - 2006-02-24 22:10:30
|
Update of /cvsroot/hibernate/Hibernate3/test/org/hibernate/test/hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21997/test/org/hibernate/test/hql Modified Files: HQLSuite.java Added Files: WithClauseTest.java Removed Files: AdHocOnTest.java Log Message: HHH-1520 --- NEW FILE: WithClauseTest.java --- // $Id: WithClauseTest.java,v 1.1 2006/02/24 22:10:26 steveebersole Exp $ package org.hibernate.test.hql; import org.hibernate.test.TestCase; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.HibernateException; import org.hibernate.QueryException; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import java.util.List; import java.util.ArrayList; import java.util.Iterator; import junit.framework.Test; import junit.framework.TestSuite; /** * Implementation of WithClauseTest. * * @author Steve Ebersole */ public class WithClauseTest extends TestCase { public WithClauseTest(String name) { super( name ); } protected String[] getMappings() { return new String[] { "hql/Animal.hbm.xml" }; } public static Test suite() { return new TestSuite( WithClauseTest.class ); } protected void configure(Configuration cfg) { super.configure( cfg ); } public void testWithClauseFailsWithFetch() { TestData data = new TestData(); data.prepare(); Session s = openSession(); Transaction txn = s.beginTransaction(); try { s.createQuery( "from Animal a inner join fetch a.offspring as o with o.bodyWeight = :someLimit" ) .setDouble( "someLimit", 1 ) .list(); fail( "ad-hoc on clause allowed with fetched association" ); } catch ( HibernateException e ) { // the expected response... } txn.commit(); s.close(); data.cleanup(); } public void testInvalidWithSemantics() { Session s = openSession(); Transaction txn = s.beginTransaction(); try { // PROBLEM : f.bodyWeight is a reference to a column on the Animal table; however, the 'f' // alias relates to the Human.friends collection which the aonther Human entity. The issue // here is the way JoinSequence and Joinable (the persister) interact to generate the // joins relating to the sublcass/superclass tables s.createQuery( "from Human h inner join h.friends as f with f.bodyWeight < :someLimit" ) .setDouble( "someLimit", 1 ) .list(); fail( "failure expected" ); } catch( QueryException qe ) { if ( qe.getMessage().indexOf( "can only reference columns in the driving table" ) < 0 ) { fail( "unexpected failure type [" + qe.getMessage() + "]" ); } } try { s.createQuery( "from Animal a inner join a.offspring o inner join o.mother as m inner join m.father as f with o.bodyWeight > 1" ) .list(); fail( "failure expected" ); } catch( QueryException qe ) { if ( qe.getMessage().indexOf( "with-clause expressions did not reference from-clause element to which the with-clause was associated" ) < 0 ) { fail( "unexpected failure type [" + qe.getMessage() + "]" ); } } try { s.createQuery( "from Human h inner join h.offspring o with o.mother.father = :cousin" ) .setEntity( "cousin", s.load( Human.class, new Long(123) ) ) .list(); fail( "failure expected" ); } catch( QueryException qe ) { if ( qe.getMessage().indexOf( "with-clause expressions did not reference from-clause element to which the with-clause was associated" ) < 0 ) { fail( "unexpected failure type [" + qe.getMessage() + "]" ); } } txn.commit(); s.close(); } public void testWithClause() { TestData data = new TestData(); data.prepare(); Session s = openSession(); Transaction txn = s.beginTransaction(); // one-to-many List list = s.createQuery( "from Human h inner join h.offspring as o with o.bodyWeight < :someLimit" ) .setDouble( "someLimit", 1 ) .list(); assertTrue( "ad-hoc on did not take effect", list.isEmpty() ); // many-to-one list = s.createQuery( "from Animal a inner join a.mother as m with m.bodyWeight < :someLimit" ) .setDouble( "someLimit", 1 ) .list(); assertTrue( "ad-hoc on did not take effect", list.isEmpty() ); // many-to-many list = s.createQuery( "from Human h inner join h.friends as f with f.nickName like 'bubba'" ) .list(); assertTrue( "ad-hoc on did not take effect", list.isEmpty() ); txn.commit(); s.close(); data.cleanup(); } private class TestData { public void prepare() { Session session = openSession(); Transaction txn = session.beginTransaction(); Human mother = new Human(); mother.setBodyWeight( 10 ); mother.setDescription( "mother" ); Human father = new Human(); father.setBodyWeight( 15 ); father.setDescription( "father" ); Human child1 = new Human(); child1.setBodyWeight( 5 ); child1.setDescription( "child1" ); Human child2 = new Human(); child2.setBodyWeight( 6 ); child2.setDescription( "child2" ); Human friend = new Human(); friend.setBodyWeight( 20 ); friend.setDescription( "friend" ); child1.setMother( mother ); child1.setFather( father ); mother.addOffspring( child1 ); father.addOffspring( child1 ); child2.setMother( mother ); child2.setFather( father ); mother.addOffspring( child2 ); father.addOffspring( child2 ); father.setFriends( new ArrayList() ); father.getFriends().add( friend ); session.save( mother ); session.save( father ); session.save( child1 ); session.save( child2 ); session.save( friend ); txn.commit(); session.close(); } public void cleanup() { Session session = openSession(); Transaction txn = session.beginTransaction(); session.createQuery( "delete Animal where mother is not null" ).executeUpdate(); List humansWithFriends = session.createQuery( "from Human h where exists(from h.friends)" ).list(); Iterator itr = humansWithFriends.iterator(); while ( itr.hasNext() ) { session.delete( itr.next() ); } session.createQuery( "delete Animal" ).executeUpdate(); txn.commit(); session.close(); } } } Index: HQLSuite.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/test/org/hibernate/test/hql/HQLSuite.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- HQLSuite.java 23 Nov 2005 16:13:11 -0000 1.4 +++ HQLSuite.java 24 Feb 2006 22:10:26 -0000 1.5 @@ -16,7 +16,7 @@ suite.addTest( HQLTest.suite() ); suite.addTest( ASTParserLoadingTest.suite() ); suite.addTest( BulkManipulationTest.suite() ); - suite.addTest( AdHocOnTest.suite() ); + suite.addTest( WithClauseTest.suite() ); // suite.addTest( ASTQueryTranslatorTest.suite() ); suite.addTest( EJBQLTest.suite() ); suite.addTest( HqlParserTest.suite() ); --- AdHocOnTest.java DELETED --- |
From: <ste...@us...> - 2006-02-24 16:57:36
|
Update of /cvsroot/hibernate/Hibernate3/src/org/hibernate/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6704/src/org/hibernate/util Modified Files: Tag: Branch_3_1 DTDEntityResolver.java Log Message: HHH-1236 & HHH-1526 Index: DTDEntityResolver.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/util/DTDEntityResolver.java,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -d -r1.7 -r1.7.2.1 --- DTDEntityResolver.java 14 Aug 2005 06:57:29 -0000 1.7 +++ DTDEntityResolver.java 24 Feb 2006 16:57:32 -0000 1.7.2.1 @@ -2,9 +2,7 @@ //Contributed by Markus Meissner package org.hibernate.util; -import java.io.IOException; import java.io.InputStream; -import java.io.ObjectInputStream; import java.io.Serializable; import org.apache.commons.logging.Log; @@ -14,68 +12,63 @@ public class DTDEntityResolver implements EntityResolver, Serializable { - private static final Log log = LogFactory.getLog(DTDEntityResolver.class); - - private static final String URL = "http://hibernate.sourceforge.net/"; - private transient ClassLoader resourceLoader; - - /** - * Default constructor using DTDEntityResolver classloader for - * resource loading. - */ - public DTDEntityResolver() { - //backward compatibility - resourceLoader = this.getClass().getClassLoader(); - } + private static final Log log = LogFactory.getLog( DTDEntityResolver.class ); - /** - * Set the class loader used to load resouces - * - * @param resourceLoader class loader to use - */ - public DTDEntityResolver(ClassLoader resourceLoader) { - this.resourceLoader = resourceLoader; - } + private static final String HIBERNATE_NAMESPACE = "http://hibernate.sourceforge.net/"; + private static final String LOCAL_NAMESPACE = "file://"; - public InputSource resolveEntity (String publicId, String systemId) { - if ( systemId!=null && systemId.startsWith(URL) ) { - log.debug("trying to locate " + systemId + " in classpath under org/hibernate/"); - // Search for DTD - String path = "org/hibernate/" + systemId.substring( URL.length() ); - InputStream dtdStream = resourceLoader==null ? - getClass().getResourceAsStream(path) : - resourceLoader.getResourceAsStream(path); - if (dtdStream==null) { - log.debug(systemId + " not found in classpath"); - if ( systemId.substring( URL.length()).indexOf("2.0")>-1 ) { - log.error("Don't use old DTDs, read the Hibernate 3.x Migration Guide!"); + public InputSource resolveEntity(String publicId, String systemId) { + if ( systemId != null ) { + log.debug( "trying to resolve system-id [" + systemId + "]" ); + if ( systemId.startsWith( HIBERNATE_NAMESPACE ) ) { + log.debug( "recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/" ); + String path = "org/hibernate/" + systemId.substring( HIBERNATE_NAMESPACE.length() ); + InputStream dtdStream = resolveInHibernateNamespace( path ); + if ( dtdStream == null ) { + log.debug( "unable to locate [" + systemId + "] on classpath" ); + if ( systemId.substring( HIBERNATE_NAMESPACE.length() ).indexOf( "2.0" ) > -1 ) { + log.error( "Don't use old DTDs, read the Hibernate 3.x Migration Guide!" ); + } + } + else { + log.debug( "located [" + systemId + "] in classpath" ); + InputSource source = new InputSource( dtdStream ); + source.setPublicId( publicId ); + source.setSystemId( systemId ); + return source; } - return null; } - else { - log.debug("found " + systemId + " in classpath"); - InputSource source = new InputSource(dtdStream); - source.setPublicId(publicId); - source.setSystemId(systemId); - return source; + else if ( systemId.startsWith( LOCAL_NAMESPACE ) ) { + log.debug( "recognized local namespace; attempting to resolve on classpath" ); + String path = systemId.substring( LOCAL_NAMESPACE.length() ); + InputStream stream = resolveInLocalNamespace( path ); + if ( stream == null ) { + log.debug( "unable to locate [" + systemId + "] on classpath" ); + } + else { + log.debug( "unable to locate [" + systemId + "] on classpath" ); + InputSource source = new InputSource( stream ); + source.setPublicId( publicId ); + source.setSystemId( systemId ); + return source; + } } } - else { - // use the default behaviour - return null; - } + // use default behavior + return null; } - private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { - /** to allow serialization of configuration */ - ois.defaultReadObject(); - this.resourceLoader = this.getClass().getClassLoader(); + protected InputStream resolveInHibernateNamespace(String path) { + return this.getClass().getClassLoader().getResourceAsStream( path ); } -} - - - - - - + protected InputStream resolveInLocalNamespace(String path) { + // attempt to find local stuff on the context classloader first... + InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream( path ); + if ( stream == null ) { + // next try our classloader + stream = getClass().getClassLoader().getResourceAsStream( path ); + } + return stream; + } +} |
From: <ste...@us...> - 2006-02-24 16:57:23
|
Update of /cvsroot/hibernate/Hibernate3/src/org/hibernate/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6653/src/org/hibernate/util Modified Files: DTDEntityResolver.java Log Message: HHH-1236 & HHH-1526 Index: DTDEntityResolver.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/util/DTDEntityResolver.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- DTDEntityResolver.java 14 Aug 2005 06:57:29 -0000 1.7 +++ DTDEntityResolver.java 24 Feb 2006 16:57:17 -0000 1.8 @@ -2,9 +2,7 @@ //Contributed by Markus Meissner package org.hibernate.util; -import java.io.IOException; import java.io.InputStream; -import java.io.ObjectInputStream; import java.io.Serializable; import org.apache.commons.logging.Log; @@ -14,68 +12,63 @@ public class DTDEntityResolver implements EntityResolver, Serializable { - private static final Log log = LogFactory.getLog(DTDEntityResolver.class); - - private static final String URL = "http://hibernate.sourceforge.net/"; - private transient ClassLoader resourceLoader; - - /** - * Default constructor using DTDEntityResolver classloader for - * resource loading. - */ - public DTDEntityResolver() { - //backward compatibility - resourceLoader = this.getClass().getClassLoader(); - } + private static final Log log = LogFactory.getLog( DTDEntityResolver.class ); - /** - * Set the class loader used to load resouces - * - * @param resourceLoader class loader to use - */ - public DTDEntityResolver(ClassLoader resourceLoader) { - this.resourceLoader = resourceLoader; - } + private static final String HIBERNATE_NAMESPACE = "http://hibernate.sourceforge.net/"; + private static final String LOCAL_NAMESPACE = "file://"; - public InputSource resolveEntity (String publicId, String systemId) { - if ( systemId!=null && systemId.startsWith(URL) ) { - log.debug("trying to locate " + systemId + " in classpath under org/hibernate/"); - // Search for DTD - String path = "org/hibernate/" + systemId.substring( URL.length() ); - InputStream dtdStream = resourceLoader==null ? - getClass().getResourceAsStream(path) : - resourceLoader.getResourceAsStream(path); - if (dtdStream==null) { - log.debug(systemId + " not found in classpath"); - if ( systemId.substring( URL.length()).indexOf("2.0")>-1 ) { - log.error("Don't use old DTDs, read the Hibernate 3.x Migration Guide!"); + public InputSource resolveEntity(String publicId, String systemId) { + if ( systemId != null ) { + log.debug( "trying to resolve system-id [" + systemId + "]" ); + if ( systemId.startsWith( HIBERNATE_NAMESPACE ) ) { + log.debug( "recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/" ); + String path = "org/hibernate/" + systemId.substring( HIBERNATE_NAMESPACE.length() ); + InputStream dtdStream = resolveInHibernateNamespace( path ); + if ( dtdStream == null ) { + log.debug( "unable to locate [" + systemId + "] on classpath" ); + if ( systemId.substring( HIBERNATE_NAMESPACE.length() ).indexOf( "2.0" ) > -1 ) { + log.error( "Don't use old DTDs, read the Hibernate 3.x Migration Guide!" ); + } + } + else { + log.debug( "located [" + systemId + "] in classpath" ); + InputSource source = new InputSource( dtdStream ); + source.setPublicId( publicId ); + source.setSystemId( systemId ); + return source; } - return null; } - else { - log.debug("found " + systemId + " in classpath"); - InputSource source = new InputSource(dtdStream); - source.setPublicId(publicId); - source.setSystemId(systemId); - return source; + else if ( systemId.startsWith( LOCAL_NAMESPACE ) ) { + log.debug( "recognized local namespace; attempting to resolve on classpath" ); + String path = systemId.substring( LOCAL_NAMESPACE.length() ); + InputStream stream = resolveInLocalNamespace( path ); + if ( stream == null ) { + log.debug( "unable to locate [" + systemId + "] on classpath" ); + } + else { + log.debug( "unable to locate [" + systemId + "] on classpath" ); + InputSource source = new InputSource( stream ); + source.setPublicId( publicId ); + source.setSystemId( systemId ); + return source; + } } } - else { - // use the default behaviour - return null; - } + // use default behavior + return null; } - private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { - /** to allow serialization of configuration */ - ois.defaultReadObject(); - this.resourceLoader = this.getClass().getClassLoader(); + protected InputStream resolveInHibernateNamespace(String path) { + return this.getClass().getClassLoader().getResourceAsStream( path ); } -} - - - - - - + protected InputStream resolveInLocalNamespace(String path) { + // attempt to find local stuff on the context classloader first... + InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream( path ); + if ( stream == null ) { + // next try our classloader + stream = getClass().getClassLoader().getResourceAsStream( path ); + } + return stream; + } +} |
From: <ste...@us...> - 2006-02-24 16:52:51
|
Update of /cvsroot/hibernate/Hibernate3/test/org/hibernate/test/proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4499/test/org/hibernate/test/proxy Modified Files: ProxyTest.java Log Message: try to protect HSQLDB from itself ;) Index: ProxyTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/test/org/hibernate/test/proxy/ProxyTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- ProxyTest.java 22 Feb 2006 21:45:23 -0000 1.13 +++ ProxyTest.java 24 Feb 2006 16:52:48 -0000 1.14 @@ -234,7 +234,9 @@ for ( int dp_indx = 0; dp_indx < nestedDataPointCount; dp_indx++ ) { DataPoint dp = new DataPoint(); dp.setDescription( "data-point [" + c_indx + ", " + dp_indx + "]" ); - dp.setX( new BigDecimal( c_indx ) ); +// more HSQLDB fun... +// dp.setX( new BigDecimal( c_indx ) ); + dp.setX( new BigDecimal( c_indx + dp_indx ) ); dp.setY( new BigDecimal( dp_indx ) ); container.getDataPoints().add( dp ); } |
From: Prasanth K. <p_k...@ya...> - 2006-02-24 14:14:12
|
Hi, I am Made Some small Modifications to the NHibernate Code. Needed Help as to if I am Going in the Right Direction. I would also Highly appreciate any Critsisims or Suggestions. Pls also Let Me Know if This would affect the Exisisting Code in Anyway. Problem Statement: I needed Dynamic Updates to Work even If I dont Load the Object in the same session. Solution: I will be creating an IClass Interface. This will have One function called GetDirtyColumns. All the Entity class Files implement this interface. Apart from all Properties Entity Class Files will also have a bool array which will keep a track of all Changed Properties. This can be done by modifying the Set Funtion of all Properties. Now I will pass this array to the EntityPersister Class. This will now work as Dynamic Update Currently works. For My modified version of updatw kindly have alook at the attached Text File. Regards Prasanth Kumar __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: <epb...@us...> - 2006-02-23 23:17:08
|
Update of /cvsroot/hibernate/HibernateExt/metadata/src/java/org/hibernate/cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18186/metadata/src/java/org/hibernate/cfg Modified Files: AnnotationBinder.java Log Message: ANN-259 (Radim Tlusty, Mat?j Kraus) Index: AnnotationBinder.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java,v retrieving revision 1.177 retrieving revision 1.178 diff -u -d -r1.177 -r1.178 --- AnnotationBinder.java 17 Feb 2006 18:47:18 -0000 1.177 +++ AnnotationBinder.java 23 Feb 2006 23:16:58 -0000 1.178 @@ -1112,12 +1112,14 @@ Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); + OnDelete onDeleteAnn = property.getAnnotation( OnDelete.class ); + boolean onDeleteCascade = onDeleteAnn != null && OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ); bindManyToOne( getCascadeStrategy( ann.cascade(), hibernateCascade ), (Ejb3JoinColumn[]) joinColumns, ann.optional(), getFetchMode( ann.fetch() ), - ignoreNotFound, inferredData.getPropertyName(), + ignoreNotFound, onDeleteCascade, inferredData.getPropertyName(), inferredData.getClassOrElementName(), ReflectionManager.INSTANCE.toXClass( ann.targetEntity() ), inferredData.getDefaultAccess(), @@ -1131,12 +1133,14 @@ Cascade hibernateCascade = property.getAnnotation( Cascade.class ); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); + OnDelete onDeleteAnn = property.getAnnotation( OnDelete.class ); + boolean onDeleteCascade = onDeleteAnn != null && OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ); bindOneToOne( getCascadeStrategy( ann.cascade(), hibernateCascade ), (Ejb3JoinColumn[]) joinColumns, ann.optional(), getFetchMode( ann.fetch() ), - ignoreNotFound, inferredData.getPropertyName(), + ignoreNotFound, onDeleteCascade, inferredData.getPropertyName(), inferredData.getClassOrElementName(), ReflectionManager.INSTANCE.toXClass( ann.targetEntity() ), inferredData.getDefaultAccess(), @@ -1611,7 +1615,7 @@ private static void bindManyToOne( String cascadeStrategy, Ejb3JoinColumn[] columns, boolean optional, FetchMode fetchMode, - boolean ignoreNotFound, String propertyName, + boolean ignoreNotFound, boolean cascadeOnDelete, String propertyName, String returnedClassName, XClass targetEntity, String propertyAccessorName, PropertyHolder propertyHolder, boolean unique, boolean isIdentifierMapper, ExtendedMappings mappings ) { @@ -1625,6 +1629,7 @@ } value.setFetchMode( fetchMode ); value.setIgnoreNotFound( ignoreNotFound ); + value.setCascadeDeleteEnabled( cascadeOnDelete ); value.setLazy( fetchMode != FetchMode.JOIN ); if ( !optional ) { for ( Ejb3JoinColumn column : columns ) { @@ -1663,7 +1668,9 @@ Ejb3JoinColumn[] columns, boolean optional, FetchMode fetchMode, - boolean ignoreNotFound, String propertyName, + boolean ignoreNotFound, + boolean cascadeOnDelete, + String propertyName, String returnedClassName, XClass targetEntity, String propertyAccessorName, @@ -1705,6 +1712,7 @@ value.setReferencedEntityName( targetEntity.getName() ); } value.setFetchMode( fetchMode ); + value.setCascadeDeleteEnabled( cascadeOnDelete ); value.setLazy( fetchMode != FetchMode.JOIN ); if ( !optional ) value.setConstrained( true ); @@ -1723,16 +1731,7 @@ mappings) ); } -// if ( ! isDefault( mappedBy ) ) value.setReferencedPropertyName( mappedBy ); -// -// String propertyRef = value.getReferencedPropertyName(); -// if ( propertyRef != null ) { -// mappings.addUniquePropertyReference( -// value.getReferencedEntityName(), -// propertyRef -// ); -// } - //value.createForeignKey(); + PropertyBinder binder = new PropertyBinder(); binder.setName( propertyName ); binder.setValue( value ); @@ -1746,8 +1745,8 @@ else { //has a FK on the table bindManyToOne( - cascadeStrategy, columns, optional, fetchMode, ignoreNotFound, propertyName, returnedClassName, - targetEntity, + cascadeStrategy, columns, optional, fetchMode, ignoreNotFound, cascadeOnDelete, + propertyName, returnedClassName, targetEntity, propertyAccessorName, propertyHolder, true, isIdentifierMapper, mappings ); } |
From: <ste...@us...> - 2006-02-23 18:22:36
|
Update of /cvsroot/hibernate/Hibernate3/test/org/hibernate/test/generatedkeys/oracle In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28905/test/org/hibernate/test/generatedkeys/oracle Modified Files: OracleGeneratedKeysTest.java Log Message: added protection for DataDirectOracle9Dialect Index: OracleGeneratedKeysTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/test/org/hibernate/test/generatedkeys/oracle/OracleGeneratedKeysTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- OracleGeneratedKeysTest.java 10 Jan 2006 23:04:27 -0000 1.3 +++ OracleGeneratedKeysTest.java 23 Feb 2006 18:22:23 -0000 1.4 @@ -2,8 +2,11 @@ import org.hibernate.test.DatabaseSpecificTestCase; import org.hibernate.Session; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; import org.hibernate.dialect.Oracle9Dialect; import org.hibernate.dialect.Dialect; +import org.hibernate.dialect.DataDirectOracle9Dialect; import junit.framework.Test; import junit.framework.TestSuite; @@ -15,6 +18,11 @@ super( x ); } + protected void configure(Configuration cfg) { + super.configure( cfg ); + cfg.setProperty( Environment.USE_GET_GENERATED_KEYS, "true" ); // make certain generated keys enabled. + } + public boolean appliesTo(Dialect dialect) { return ( dialect instanceof Oracle9Dialect ); } @@ -30,6 +38,10 @@ } public void testJDBC3GetGeneratedKeysSupportOnOracle() { + if ( getDialect() instanceof DataDirectOracle9Dialect ) { + reportSkip( "DataDirect drivers known to not support JDBC3 getGeneratedKeys for Oracle", "oracle getGeneratedKeys support" ); + return; + } Session session = openSession(); session.beginTransaction(); |
From: <max...@us...> - 2006-02-23 18:05:38
|
Update of /cvsroot/hibernate/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15356/src/test/org/hibernate/tool/hbm2x Modified Files: Hbm2SeamTest.java GenerateFromJDBCTest.java Log Message: HBX-574 column exclude + fixed some tests Index: Hbm2SeamTest.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2SeamTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Hbm2SeamTest.java 7 Feb 2006 20:22:46 -0000 1.4 +++ Hbm2SeamTest.java 23 Feb 2006 18:05:21 -0000 1.5 @@ -43,8 +43,15 @@ } public void testArtifactCollection() { - assertEquals(artifactCollector.getFileCount("java"), 2); + assertEquals(12,artifactCollector.getFileCount("java")); + assertEquals(1,artifactCollector.getFileCount("html")); + assertEquals(4,artifactCollector.getFileCount("jsp")); + assertEquals(6,artifactCollector.getFileCount("xml")); + assertEquals(3,artifactCollector.getFileCount("properties")); + assertEquals(1,artifactCollector.getFileCount("txt")); + assertEquals(1,artifactCollector.getFileCount("css")); + assertEquals(7,artifactCollector.getFileTypes().size()); } protected String getBaseForMappings() { Index: GenerateFromJDBCTest.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenerateFromJDBCTest.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- GenerateFromJDBCTest.java 31 Jan 2006 08:26:27 -0000 1.18 +++ GenerateFromJDBCTest.java 23 Feb 2006 18:05:21 -0000 1.19 @@ -112,7 +112,7 @@ // Validate the Generator and it has no arguments XPath xpath = DocumentHelper.createXPath("//hibernate-configuration/session-factory/mapping"); Element[] elements = (Element[]) xpath.selectNodes(document).toArray(new Element[0]); - assertEquals(elements.length , 2); + assertEquals(2,elements.length); for (int i = 0; i < elements.length; i++) { Element element = elements[i]; |
From: <max...@us...> - 2006-02-23 18:05:30
|
Update of /cvsroot/hibernate/HibernateExt/tools/src/testsupport In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15356/src/testsupport Modified Files: anttest-build.xml NoopReverseEngineeringStrategy.java Log Message: HBX-574 column exclude + fixed some tests Index: anttest-build.xml =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/testsupport/anttest-build.xml,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- anttest-build.xml 17 Feb 2006 16:31:57 -0000 1.28 +++ anttest-build.xml 23 Feb 2006 18:05:22 -0000 1.29 @@ -44,6 +44,7 @@ <hbm2ddl update="true" outputfilename="updateonly.sql" format="true"/> <hbm2doc/> </hibernatetool> + </target> <target name="testantjdbccfg"> @@ -274,9 +275,11 @@ <antcall target="afterCfg2hbm"/> </target> - <mkdir dir="${build.dir}/noconinfo"/> + <target name="noconinfoexport" description="hbm2ddl without connection info"> - <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="tasks.classpath"/> + <mkdir dir="${build.dir}/noconinfo"/> + + <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="tasks.classpath"/> <hibernatetool destdir="${build.dir}/noconinfo"> <configuration configurationfile="noconnectioninfo-hibernate.cfg.xml"> Index: NoopReverseEngineeringStrategy.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/testsupport/NoopReverseEngineeringStrategy.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- NoopReverseEngineeringStrategy.java 8 Jan 2006 15:08:01 -0000 1.12 +++ NoopReverseEngineeringStrategy.java 23 Feb 2006 18:05:22 -0000 1.13 @@ -94,4 +94,9 @@ // TODO Auto-generated method stub return null; } + + public boolean excludeColumn(TableIdentifier identifier, String columnName) { + // TODO Auto-generated method stub + return false; + } } |
From: <max...@us...> - 2006-02-23 18:05:29
|
Update of /cvsroot/hibernate/HibernateExt/tools/src/java/org/hibernate/cfg/reveng In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15356/src/java/org/hibernate/cfg/reveng Modified Files: JDBCReader.java OverrideBinder.java OverrideRepository.java DelegatingReverseEngineeringStrategy.java ReverseEngineeringStrategy.java DefaultReverseEngineeringStrategy.java Log Message: HBX-574 column exclude + fixed some tests Index: JDBCReader.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- JDBCReader.java 8 Feb 2006 11:56:35 -0000 1.30 +++ JDBCReader.java 23 Feb 2006 18:05:21 -0000 1.31 @@ -493,8 +493,14 @@ String sqlTypeName = (String) columnRs.get("TYPE_NAME"); String columnName = (String) columnRs.get("COLUMN_NAME"); + String comment = (String) columnRs.get("REMARKS"); + TableIdentifier ti = TableIdentifier.create(table); + if(revengStrategy.excludeColumn(ti, columnName)) { + log.debug("Column " + ti + "." + columnName + " excluded by strategy"); + continue; + } if(!tableName.equals(table.getName())) { log.debug("Table name " + tableName + " does not match requested " + table.getName() + ". Ignoring column " + columnName + " since it either is invalid or a duplicate" ); continue; Index: OverrideBinder.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideBinder.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- OverrideBinder.java 27 Jan 2006 00:51:37 -0000 1.12 +++ OverrideBinder.java 23 Feb 2006 18:05:21 -0000 1.13 @@ -154,14 +154,21 @@ if(StringHelper.isNotEmpty(attributeValue)) { column.setSqlTypeCode(new Integer(JDBCToHibernateTypeHelper.getJDBCType(attributeValue))); } + + TableIdentifier tableIdentifier = TableIdentifier.create(table); if(table.getColumn(column)!=null) { - throw new MappingException("Column " + column.getName() + " already exists in table " + TableIdentifier.create(table) ); + throw new MappingException("Column " + column.getName() + " already exists in table " + tableIdentifier ); } table.addColumn(column); columnNames.add(column.getName()); - repository.setTypeNameForColumn(TableIdentifier.create(table), column.getName(), element.attributeValue("type")); - repository.setPropertyNameForColumn(TableIdentifier.create(table), column.getName(), element.attributeValue("property")); + repository.setTypeNameForColumn(tableIdentifier, column.getName(), element.attributeValue("type")); + repository.setPropertyNameForColumn(tableIdentifier, column.getName(), element.attributeValue("property")); + + boolean excluded = Boolean.valueOf(element.attributeValue("exclude")).booleanValue(); + if(excluded) { + repository.setExcludedColumn(tableIdentifier, column.getName()); + } String foreignTableName = element.attributeValue("foreign-table"); if(foreignTableName!=null) { Index: OverrideRepository.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- OverrideRepository.java 27 Jan 2006 00:51:37 -0000 1.18 +++ OverrideRepository.java 23 Feb 2006 18:05:21 -0000 1.19 @@ -6,10 +6,12 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import net.sf.cglib.core.KeyFactory; @@ -48,9 +50,14 @@ final private Map primaryKeyColumnsForTable; + final private Set excludedColumns; + + final private Map tableToClassName; + private String defaultCatalog; private String defaultSchema; - private HashMap tableToClassName; + + public OverrideRepository(String defaultCatalog, String defaultSchema) { this.defaultCatalog = null; @@ -67,6 +74,7 @@ identifierPropertiesForTable = new HashMap(); primaryKeyColumnsForTable = new HashMap(); tableToClassName = new HashMap(); + excludedColumns = new HashSet(); } public OverrideRepository addFile(File xmlFile) { @@ -241,11 +249,15 @@ return OverrideRepository.this.excludeTable(ti); } + public boolean excludeColumn(TableIdentifier identifier, String columnName) { + return excludedColumns.contains(TABLECOLUMN_KEY_FACTORY.newInstance(identifier, columnName)); + } + public String columnToHibernateTypeName(TableIdentifier table, String columnName, int sqlType, int length, int precision, int scale, boolean nullable) { String result = null; String location = ""; if(table!=null) { - location = "Table: " + Table.qualify(table.getCatalog(), table.getSchema(), table.getName() ); + location = "Table: " + Table.qualify(table.getCatalog(), table.getSchema(), table.getName() ) + " column: " + columnName; } else { location += " Column: " + columnName + " l:" + length + " p:" + precision + " s:" + scale; } @@ -372,6 +384,10 @@ } } + public void setExcludedColumn(TableIdentifier tableIdentifier, String columnName) { + excludedColumns.add(TABLECOLUMN_KEY_FACTORY.newInstance(tableIdentifier, columnName)); + } + public void setPropertyNameForColumn(TableIdentifier identifier, String columnName, String property) { if(StringHelper.isNotEmpty(property)) { propertyNameForColumn.put(TABLECOLUMN_KEY_FACTORY.newInstance(identifier, columnName), property); @@ -400,5 +416,7 @@ public String getSchema(String string) { return string==null?defaultSchema:string; } + + } Index: DelegatingReverseEngineeringStrategy.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DelegatingReverseEngineeringStrategy.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- DelegatingReverseEngineeringStrategy.java 25 Jan 2006 15:59:28 -0000 1.16 +++ DelegatingReverseEngineeringStrategy.java 23 Feb 2006 18:05:21 -0000 1.17 @@ -25,6 +25,10 @@ public boolean excludeTable(TableIdentifier ti) { return delegate==null?false:delegate.excludeTable(ti); } + + public boolean excludeColumn(TableIdentifier identifier, String columnName) { + return delegate==null?false:delegate.excludeColumn(identifier, columnName); + } public String foreignKeyToCollectionName(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns, boolean uniqueReference) { return delegate==null?null:delegate.foreignKeyToCollectionName(keyname, fromTable, fromColumns, referencedTable, referencedColumns, uniqueReference); Index: ReverseEngineeringStrategy.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringStrategy.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- ReverseEngineeringStrategy.java 31 Jan 2006 06:17:07 -0000 1.14 +++ ReverseEngineeringStrategy.java 23 Feb 2006 18:05:21 -0000 1.15 @@ -41,6 +41,8 @@ public boolean excludeTable(TableIdentifier ti); + public boolean excludeColumn(TableIdentifier identifier, String columnName); + /** * Gets the preferred Hibernate type for an SQL type. * @param table name of the table, can be null @@ -96,8 +98,6 @@ public String getOptimisticLockColumnName(TableIdentifier identifier); public Boolean useColumnForOptimisticLock(TableIdentifier identifier, String column); - - - + } Index: DefaultReverseEngineeringStrategy.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- DefaultReverseEngineeringStrategy.java 25 Jan 2006 16:55:24 -0000 1.23 +++ DefaultReverseEngineeringStrategy.java 23 Feb 2006 18:05:21 -0000 1.24 @@ -115,6 +115,10 @@ if(ti.getName().startsWith("BIN$")) return true; // hard code oracle recycle bin names. Better than requiring users to do it manually. TODO: make it dependent on dialect. return false; } + + public boolean excludeColumn(TableIdentifier identifier, String columnName) { + return false; + } public String tableToClassName(TableIdentifier tableIdentifier) { @@ -166,6 +170,7 @@ public Boolean useColumnForOptimisticLock(TableIdentifier identifier, String column) { return AUTO_OPTIMISTICLOCK_COLUMNS.contains(column.toLowerCase())?Boolean.TRUE:Boolean.FALSE; } + } |
From: <max...@us...> - 2006-02-23 18:05:29
|
Update of /cvsroot/hibernate/HibernateExt/tools/src/test/org/hibernate/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15356/src/test/org/hibernate/tool Modified Files: JDBCMetaDataBinderTestCase.java Log Message: HBX-574 column exclude + fixed some tests Index: JDBCMetaDataBinderTestCase.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/test/org/hibernate/tool/JDBCMetaDataBinderTestCase.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- JDBCMetaDataBinderTestCase.java 6 Feb 2006 09:08:09 -0000 1.14 +++ JDBCMetaDataBinderTestCase.java 23 Feb 2006 18:05:22 -0000 1.15 @@ -67,7 +67,7 @@ * @param sqls * @throws SQLException */ - protected void executeDDL(String[] sqls) throws SQLException { + protected void executeDDL(String[] sqls, boolean ignoreErrors) throws SQLException { Configuration configuration = new Configuration(); Settings testSettings = configuration.buildSettings(); @@ -83,14 +83,18 @@ for (int i = 0; i < sqls.length; i++) { - String string = sqls[i]; - System.out.println("Execute: " + string); + String ddlsql = sqls[i]; + System.out.println("Execute: " + ddlsql); - try { - statement.execute(string); + try { + statement.execute(ddlsql); } - catch (SQLException se) { - throw se; + catch (SQLException se) { + if(ignoreErrors) { + System.err.println(se.toString() + " for " + ddlsql); + } else { + throw se; + } } } if (statement!=null) statement.close(); @@ -106,7 +110,7 @@ if(cfg==null) { // only do if we haven't done it before - to save time! try { - executeDDL(getDropSQL() ); + executeDDL(getDropSQL(), true); } catch (SQLException se) { System.err.println("Error while dropping - normally ok."); @@ -118,17 +122,14 @@ String[] sqls = getCreateSQL(); - executeDDL(sqls); + executeDDL(sqls, false); cfg.readFromJDBC(); } } - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - executeDDL(getDropSQL() ); + protected void tearDown() throws Exception { + executeDDL(getDropSQL(), true ); super.tearDown(); } /** |
Update of /cvsroot/hibernate/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15356/src/test/org/hibernate/tool/test/jdbc2cfg Modified Files: CompositeIdTest.java overridetest.reveng.xml OverrideBinderTest.java Log Message: HBX-574 column exclude + fixed some tests Index: CompositeIdTest.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/CompositeIdTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- CompositeIdTest.java 7 Feb 2006 14:02:15 -0000 1.13 +++ CompositeIdTest.java 23 Feb 2006 18:05:21 -0000 1.14 @@ -247,7 +247,7 @@ SessionFactory factory = derived.buildSessionFactory(); Session session = factory.openSession(); - executeDDL(getGenDataSQL() ); + executeDDL(getGenDataSQL(), false); session.createQuery("from Lineitem").list(); List list = session.createQuery("from Product").list(); assertEquals(2,list.size() ); Index: overridetest.reveng.xml =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/overridetest.reveng.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- overridetest.reveng.xml 31 Oct 2005 12:46:55 -0000 1.13 +++ overridetest.reveng.xml 23 Feb 2006 18:05:21 -0000 1.14 @@ -62,6 +62,10 @@ </foreign-key> </table> + <table name="EXCOLUMNS"> + <column name="EXCOLUMN" exclude="true"/> + </table> + <table name="TblTest" class="org.test.Test"/> Index: OverrideBinderTest.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- OverrideBinderTest.java 27 Jan 2006 10:20:14 -0000 1.22 +++ OverrideBinderTest.java 23 Feb 2006 18:05:21 -0000 1.23 @@ -21,6 +21,7 @@ import org.hibernate.cfg.reveng.SQLTypeMapping; import org.hibernate.cfg.reveng.TableFilter; import org.hibernate.cfg.reveng.TableIdentifier; +import org.hibernate.mapping.Column; import org.hibernate.mapping.ForeignKey; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; @@ -266,6 +267,25 @@ assertTrue(tf.exclude(new TableIdentifier("heremaxsub") ).booleanValue() ); } + public void testColumnExclude() { + + OverrideRepository or = buildOverrideRepository(); + or.addResource(OVERRIDETEST_REVENG_XML); + + ReverseEngineeringStrategy reverseEngineeringStrategy = or.getReverseEngineeringStrategy(); + + assertFalse(reverseEngineeringStrategy.excludeColumn(new TableIdentifier("EXCOLUMNS"), "blah")); + assertFalse(reverseEngineeringStrategy.excludeColumn(new TableIdentifier("EXCOLUMNS"), "NAME")); + assertTrue(reverseEngineeringStrategy.excludeColumn(new TableIdentifier("EXCOLUMNS"), "EXCOLUMN")); + + Table table = findTable(identifier("excolumns")); + assertNotNull(table); + + assertNotNull(table.getColumn(new Column("name"))); + assertNull(table.getColumn(new Column("excolumn"))); + + } + public void testSimpleUserDefinedForeignKeys() { Table table = findTable(identifier("Orders") ); @@ -350,13 +370,15 @@ "create table customer ( custid varchar(10), name varchar(20) )", "create table orders ( orderid varchar(10), name varchar(20), custid varchar(10), completed numeric(1) not null, verified numeric(1), primary key (orderid) )", "create table parent ( id varchar(10), name varchar(20))", - "create table children ( id varchar(10), parentid varchar(10), name varchar(20) )" + "create table children ( id varchar(10), parentid varchar(10), name varchar(20) )", + "create table excolumns (id varchar(12), name varchar(20), excolumn numeric(10,0) )" }; } protected String[] getDropSQL() { return new String[] { + "drop table excolumns", "drop table parent", "drop table children", "drop table customer", |
From: <max...@us...> - 2006-02-23 18:05:26
|
Update of /cvsroot/hibernate/HibernateExt/tools/src/test/org/hibernate/tool/ant In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15356/src/test/org/hibernate/tool/ant Modified Files: HibernateToolTest.java Log Message: HBX-574 column exclude + fixed some tests Index: HibernateToolTest.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- HibernateToolTest.java 17 Feb 2006 16:31:57 -0000 1.19 +++ HibernateToolTest.java 23 Feb 2006 18:05:21 -0000 1.20 @@ -138,8 +138,7 @@ executeTarget("testexceptions"); fail("should have failed with an exception!"); } catch(BuildException be) { - // should happen! - assertTrue(be.getMessage().indexOf("No exporters specified")>=0); + // should happen! } } |
From: <ste...@us...> - 2006-02-23 17:32:53
|
Update of /cvsroot/hibernate/Hibernate3/src/org/hibernate/persister/entity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26622/src/org/hibernate/persister/entity Added Files: Lockable.java Log Message: HHH-1518 : locking strategies --- NEW FILE: Lockable.java --- package org.hibernate.persister.entity; /** * Contract for things that can be locked via a {@link org.hibernate.dialect.lock.LockingStrategy} * * @author Steve Ebersole * @since 3.2 */ public interface Lockable extends EntityPersister { /** * Locks are always applied to the "root table". * * @return The root table name */ public String getRootTableName(); /** * Get the names of columns on the root table used to persist the identifier. * * @return The root table identifier column names. */ public String[] getRootTableIdentifierColumnNames(); /** * For versioned entities, get the name of the column (again, expected on the * root table) used to store the version values. * * @return The version column name. */ public String getVersionColumnName(); } |
From: <ste...@us...> - 2006-02-23 17:32:24
|
Update of /cvsroot/hibernate/Hibernate3/test/org/hibernate/test/ejb3/lock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26398/test/org/hibernate/test/ejb3/lock Modified Files: EJB3LockTest.java RepeatableReadTest.java Log Message: protect from connections in READ_UNCOMMITTED isolation Index: EJB3LockTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/test/org/hibernate/test/ejb3/lock/EJB3LockTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- EJB3LockTest.java 17 Feb 2006 03:14:14 -0000 1.2 +++ EJB3LockTest.java 23 Feb 2006 17:32:17 -0000 1.3 @@ -135,6 +135,9 @@ * a new Hibernate LockMode was added to support this behavior: {@link LockMode#FORCE}. */ public void testLockModeTypeWrite() { + if ( ! readCommittedIsolationMaintained( "ejb3 lock tests" ) ) { + return; + } final String initialName = "lock test"; // set up some test data Session s1 = getSessions().openSession(); Index: RepeatableReadTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/test/org/hibernate/test/ejb3/lock/RepeatableReadTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- RepeatableReadTest.java 14 Feb 2006 03:24:18 -0000 1.1 +++ RepeatableReadTest.java 23 Feb 2006 17:32:17 -0000 1.2 @@ -91,6 +91,9 @@ } public void testStaleVersionedInstanceFoundOnLock() { + if ( ! readCommittedIsolationMaintained( "repeatable read tests" ) ) { + return; + } String check = "EJB3 Specification"; Session s1 = getSessions().openSession(); Transaction t1 = s1.beginTransaction(); @@ -183,6 +186,9 @@ } public void testStaleNonVersionedInstanceFoundOnLock() { + if ( ! readCommittedIsolationMaintained( "repeatable read tests" ) ) { + return; + } String check = "Lock Modes"; Session s1 = getSessions().openSession(); Transaction t1 = s1.beginTransaction(); |
From: <ste...@us...> - 2006-02-23 17:30:47
|
Update of /cvsroot/hibernate/Hibernate3/src/org/hibernate/persister/entity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25533/src/org/hibernate/persister/entity Modified Files: AbstractEntityPersister.java Log Message: HHH-1518 : locking strategies Index: AbstractEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- AbstractEntityPersister.java 15 Feb 2006 22:28:15 -0000 1.30 +++ AbstractEntityPersister.java 23 Feb 2006 17:30:39 -0000 1.31 @@ -26,6 +26,8 @@ import org.hibernate.MappingException; import org.hibernate.QueryException; import org.hibernate.StaleObjectStateException; +import org.hibernate.dialect.lock.LockingStrategy; +import org.hibernate.dialect.lock.SelectLockingStrategy; import org.hibernate.cache.CacheConcurrencyStrategy; import org.hibernate.cache.CacheKey; import org.hibernate.cache.entry.CacheEntry; @@ -91,7 +93,7 @@ */ public abstract class AbstractEntityPersister implements OuterJoinLoadable, Queryable, ClassMetadata, UniqueKeyLoadable, - SQLLoadable, LazyPropertyInitializer, PostInsertIdentityPersister { + SQLLoadable, LazyPropertyInitializer, PostInsertIdentityPersister, Lockable { private static final Log log = LogFactory.getLog( AbstractEntityPersister.class ); @@ -858,10 +860,6 @@ return lazyProperties; } - private String getLockString(LockMode lockMode) { - return ( String ) lockers.get( lockMode ); - } - public boolean isBatchLoadable() { return batchSize > 1; } @@ -1151,65 +1149,6 @@ .toStatementString(); } - /** - * Do a version check - */ - public void lock(Serializable id, Object version, Object object, LockMode lockMode, SessionImplementor session) - throws HibernateException { - - if ( lockMode != LockMode.NONE ) { - - if ( log.isTraceEnabled() ) { - log.trace( "Locking entity: " + MessageHelper.infoString( this, id, getFactory() ) ); - if ( isVersioned() ) { - log.trace( "Version: " + version ); - } - } - - final String sql = getLockString( lockMode ); - - try { - - PreparedStatement st = session.getBatcher().prepareSelectStatement( sql ); - try { - getIdentifierType().nullSafeSet( st, id, 1, session ); - if ( isVersioned() ) { - getVersionType().nullSafeSet( st, version, getIdentifierColumnSpan() + 1, session ); - } - - ResultSet rs = st.executeQuery(); - try { - if ( !rs.next() ) { - if ( getFactory().getStatistics().isStatisticsEnabled() ) { - getFactory().getStatisticsImplementor() - .optimisticFailure( getEntityName() ); - } - throw new StaleObjectStateException( getEntityName(), id ); - } - } - finally { - rs.close(); - } - } - finally { - session.getBatcher().closeStatement( st ); - } - - } - catch ( SQLException sqle ) { - throw JDBCExceptionHelper.convert( - getFactory().getSQLExceptionConverter(), - sqle, - "could not lock: " + - MessageHelper.infoString( this, id, getFactory() ), - sql - ); - } - - } - - } - public Object forceVersionIncrement(Serializable id, Object currentVersion, SessionImplementor session) { if ( !isVersioned() ) { throw new AssertionFailure( "cannot force version increment on non-versioned entity" ); @@ -1319,32 +1258,124 @@ } - /** - * Generate the SQL that pessimistic locks a row by id (and version) - */ - protected String generateLockString(LockMode lockMode) { + protected void initLockers() { + lockers.put( LockMode.READ, generateLocker( LockMode.READ ) ); + lockers.put( LockMode.UPGRADE, generateLocker( LockMode.UPGRADE ) ); + lockers.put( LockMode.UPGRADE_NOWAIT, generateLocker( LockMode.UPGRADE_NOWAIT ) ); + } - SimpleSelect select = new SimpleSelect( getFactory().getDialect() ) - .setLockMode( lockMode ) - .setTableName( getVersionedTableName() ) - .addColumn( rootTableKeyColumnNames[0] ) - .addCondition( rootTableKeyColumnNames, "=?" ); - if ( isVersioned() ) { - select.addCondition( getVersionColumnName(), "=?" ); - } - if ( getFactory().getSettings().isCommentsEnabled() ) { - select.setComment( "lock " + getEntityName() ); - } - return select.toStatementString(); + protected LockingStrategy generateLocker(LockMode lockMode) { + return factory.getDialect().getLockingStrategy( this, lockMode ); + } + private LockingStrategy getLocker(LockMode lockMode) { + return ( LockingStrategy ) lockers.get( lockMode ); } - protected void initLockers() { - lockers.put( LockMode.READ, generateLockString( LockMode.READ ) ); - lockers.put( LockMode.UPGRADE, generateLockString( LockMode.UPGRADE ) ); - lockers.put( LockMode.UPGRADE_NOWAIT, generateLockString( LockMode.UPGRADE_NOWAIT ) ); + public void lock( + Serializable id, + Object version, + Object object, + LockMode lockMode, + SessionImplementor session) throws HibernateException { + getLocker( lockMode ).lock( id, version, object, session ); } + public String getRootTableName() { + return getSubclassTableName( 0 ); + } + + public String[] getRootTableIdentifierColumnNames() { + return getRootTableKeyColumnNames(); + } + +// /** +// * Generate the SQL that pessimistic locks a row by id (and version) +// */ +// protected String generateLockString(LockMode lockMode) { +// SimpleSelect select = new SimpleSelect( getFactory().getDialect() ) +// .setLockMode( lockMode ) +// .setTableName( getVersionedTableName() ) +// .addColumn( rootTableKeyColumnNames[0] ) +// .addCondition( rootTableKeyColumnNames, "=?" ); +// if ( isVersioned() ) { +// select.addCondition( getVersionColumnName(), "=?" ); +// } +// if ( getFactory().getSettings().isCommentsEnabled() ) { +// select.setComment( "lock " + getEntityName() ); +// } +// return select.toStatementString(); +// } +// +// protected void initLockers() { +// lockers.put( LockMode.READ, generateLockString( LockMode.READ ) ); +// lockers.put( LockMode.UPGRADE, generateLockString( LockMode.UPGRADE ) ); +// lockers.put( LockMode.UPGRADE_NOWAIT, generateLockString( LockMode.UPGRADE_NOWAIT ) ); +// } +// +// private String getLockString(LockMode lockMode) { +// return ( String ) lockers.get( lockMode ); +// } +// +// /** +// * Do a version check +// */ +// public void lock(Serializable id, Object version, Object object, LockMode lockMode, SessionImplementor session) +// throws HibernateException { +// +// if ( lockMode != LockMode.NONE ) { +// +// if ( log.isTraceEnabled() ) { +// log.trace( "Locking entity: " + MessageHelper.infoString( this, id, getFactory() ) ); +// if ( isVersioned() ) { +// log.trace( "Version: " + version ); +// } +// } +// +// final String sql = getLockString( lockMode ); +// +// try { +// +// PreparedStatement st = session.getBatcher().prepareSelectStatement( sql ); +// try { +// getIdentifierType().nullSafeSet( st, id, 1, session ); +// if ( isVersioned() ) { +// getVersionType().nullSafeSet( st, version, getIdentifierColumnSpan() + 1, session ); +// } +// +// ResultSet rs = st.executeQuery(); +// try { +// if ( !rs.next() ) { +// if ( getFactory().getStatistics().isStatisticsEnabled() ) { +// getFactory().getStatisticsImplementor() +// .optimisticFailure( getEntityName() ); +// } +// throw new StaleObjectStateException( getEntityName(), id ); +// } +// } +// finally { +// rs.close(); +// } +// } +// finally { +// session.getBatcher().closeStatement( st ); +// } +// +// } +// catch ( SQLException sqle ) { +// throw JDBCExceptionHelper.convert( +// getFactory().getSQLExceptionConverter(), +// sqle, +// "could not lock: " + +// MessageHelper.infoString( this, id, getFactory() ), +// sql +// ); +// } +// +// } +// +// } + public String[] toColumns(String alias, String propertyName) throws QueryException { return propertyMapping.toColumns( alias, propertyName ); } |
From: <ste...@us...> - 2006-02-23 17:30:46
|
Update of /cvsroot/hibernate/Hibernate3/src/org/hibernate/dialect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25533/src/org/hibernate/dialect Modified Files: Dialect.java FrontBaseDialect.java HSQLDialect.java MckoiDialect.java PointbaseDialect.java RDMSOS2200Dialect.java SQLServerDialect.java TimesTenDialect.java Log Message: HHH-1518 : locking strategies Index: Dialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/dialect/Dialect.java,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- Dialect.java 28 Jan 2006 12:07:25 -0000 1.66 +++ Dialect.java 23 Feb 2006 17:30:39 -0000 1.67 @@ -18,11 +18,14 @@ import org.hibernate.LockMode; import org.hibernate.MappingException; import org.hibernate.QueryException; +import org.hibernate.persister.entity.Lockable; import org.hibernate.cfg.Environment; import org.hibernate.dialect.function.CastFunction; import org.hibernate.dialect.function.SQLFunction; import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.StandardSQLFunction; +import org.hibernate.dialect.lock.LockingStrategy; +import org.hibernate.dialect.lock.SelectLockingStrategy; import org.hibernate.engine.Mapping; import org.hibernate.exception.SQLExceptionConverter; import org.hibernate.exception.SQLStateConverter; @@ -1010,5 +1013,16 @@ return "current_timestamp"; } - + /** + * Get a strategy instance which knows how to acquire a database-level lock + * of the specified mode for this dialect. + * + * @param lockable The persister for the entity to be locked. + * @param lockMode The type of lock to be acquired. + * @return The appropriate locking strategy. + * @since 3.2 + */ + public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { + return new SelectLockingStrategy( lockable, lockMode ); + } } Index: FrontBaseDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/dialect/FrontBaseDialect.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- FrontBaseDialect.java 12 Aug 2005 01:57:48 -0000 1.7 +++ FrontBaseDialect.java 23 Feb 2006 17:30:39 -0000 1.8 @@ -1,6 +1,12 @@ //$Id$ package org.hibernate.dialect; +import org.hibernate.dialect.lock.LockingStrategy; +import org.hibernate.dialect.lock.UpdateLockingStrategy; +import org.hibernate.dialect.lock.SelectLockingStrategy; +import org.hibernate.persister.entity.Lockable; +import org.hibernate.LockMode; + import java.sql.Types; /** @@ -72,4 +78,14 @@ public boolean isCurrentTimestampSelectStringCallable() { return true; } + + public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { + // Frontbase has no known variation of a "SELECT ... FOR UPDATE" syntax... + if ( lockMode.greaterThan( LockMode.READ ) ) { + return new UpdateLockingStrategy( lockable, lockMode ); + } + else { + return new SelectLockingStrategy( lockable, lockMode ); + } + } } Index: HSQLDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/dialect/HSQLDialect.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- HSQLDialect.java 27 Nov 2005 22:42:03 -0000 1.36 +++ HSQLDialect.java 23 Feb 2006 17:30:39 -0000 1.37 @@ -3,16 +3,27 @@ import java.sql.SQLException; import java.sql.Types; +import java.io.Serializable; import org.hibernate.Hibernate; +import org.hibernate.LockMode; +import org.hibernate.StaleObjectStateException; +import org.hibernate.JDBCException; +import org.hibernate.HibernateException; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.persister.entity.Lockable; import org.hibernate.util.ReflectHelper; import org.hibernate.cfg.Environment; import org.hibernate.dialect.function.NoArgSQLFunction; import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction; +import org.hibernate.dialect.lock.LockingStrategy; +import org.hibernate.dialect.lock.SelectLockingStrategy; import org.hibernate.exception.JDBCExceptionHelper; import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.ViolatedConstraintNameExtracter; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * An SQL dialect compatible with HSQLDB (Hypersonic SQL). @@ -23,6 +34,8 @@ */ public class HSQLDialect extends Dialect { + private static final Log log = LogFactory.getLog( HSQLDialect.class ); + private boolean schemaSupport; public HSQLDialect() { @@ -185,8 +198,8 @@ public String[] getCreateSequenceStrings(String sequenceName) { return new String[] { "create table dual_" + sequenceName + " (zero integer)", - "insert into dual_" + sequenceName + " values (0)", - "create sequence " + sequenceName + " start with 1" + "insert into dual_" + sequenceName + " values (0)", + "create sequence " + sequenceName + " start with 1" }; } @@ -273,4 +286,34 @@ return false; } + public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { + // HSQLDB only supports READ_UNCOMMITTED transaction isolation + return new ReadUncommittedLockingStrategy( lockable, lockMode ); + } + + public static class ReadUncommittedLockingStrategy extends SelectLockingStrategy { + public ReadUncommittedLockingStrategy(Lockable lockable, LockMode lockMode) { + super( lockable, lockMode ); + } + + public void lock(Serializable id, Object version, Object object, SessionImplementor session) + throws StaleObjectStateException, JDBCException { + if ( getLockMode().greaterThan( LockMode.READ ) ) { + throw new HibernateException( "HSQLDB supports only READ_UNCOMMITTED isolation" ); + } + else { + super.lock( id, version, object, session ); + } + } + + protected String generateLockString() { + if ( getLockMode().greaterThan( LockMode.READ ) ) { + log.info( "generating locking strategy [" + getLockMode() + "]; HSQLDB supports only READ_UNCOMMITTED isolation" ); + return null; + } + else { + return super.generateLockString(); + } + } + } } Index: MckoiDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/dialect/MckoiDialect.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- MckoiDialect.java 7 Jul 2005 02:39:10 -0000 1.7 +++ MckoiDialect.java 23 Feb 2006 17:30:39 -0000 1.8 @@ -4,8 +4,13 @@ import java.sql.Types; import org.hibernate.Hibernate; +import org.hibernate.LockMode; +import org.hibernate.persister.entity.Lockable; import org.hibernate.cfg.Environment; import org.hibernate.dialect.function.StandardSQLFunction; +import org.hibernate.dialect.lock.LockingStrategy; +import org.hibernate.dialect.lock.UpdateLockingStrategy; +import org.hibernate.dialect.lock.SelectLockingStrategy; import org.hibernate.sql.CaseFragment; import org.hibernate.sql.MckoiCaseFragment; @@ -81,4 +86,13 @@ return new MckoiCaseFragment(); } + public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { + // Mckoi has no known variation of a "SELECT ... FOR UPDATE" syntax... + if ( lockMode.greaterThan( LockMode.READ ) ) { + return new UpdateLockingStrategy( lockable, lockMode ); + } + else { + return new SelectLockingStrategy( lockable, lockMode ); + } + } } Index: PointbaseDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/dialect/PointbaseDialect.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- PointbaseDialect.java 26 Oct 2004 15:41:00 -0000 1.3 +++ PointbaseDialect.java 23 Feb 2006 17:30:39 -0000 1.4 @@ -2,6 +2,12 @@ //Created on 04 February 2002, 17:35 package org.hibernate.dialect; +import org.hibernate.dialect.lock.LockingStrategy; +import org.hibernate.dialect.lock.UpdateLockingStrategy; +import org.hibernate.dialect.lock.SelectLockingStrategy; +import org.hibernate.persister.entity.Lockable; +import org.hibernate.LockMode; + import java.sql.Types; /** @@ -51,11 +57,13 @@ return ""; } + public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { + // Pointbase has no known variation of a "SELECT ... FOR UPDATE" syntax... + if ( lockMode.greaterThan( LockMode.READ ) ) { + return new UpdateLockingStrategy( lockable, lockMode ); + } + else { + return new SelectLockingStrategy( lockable, lockMode ); + } + } } - - - - - - - Index: RDMSOS2200Dialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/dialect/RDMSOS2200Dialect.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- RDMSOS2200Dialect.java 18 Nov 2005 22:08:05 -0000 1.1 +++ RDMSOS2200Dialect.java 23 Feb 2006 17:30:39 -0000 1.2 @@ -1,357 +1,322 @@ -/* - * Created on Aug 24, 2005 - * This is the Hibernate dialect for the Unisys 2200 Relational Database (RDMS). - * This dialect was developed for use with Hibernate 3.0.5. Other versions may - * require modifications to the dialect. - * - * Version History: - * Also change the version displayed below in the constructor - * 1.1 - * 1.0 2005-10-24 CDH - First dated version for use with CP 11 - */ -package org.hibernate.dialect; - -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.function.NoArgSQLFunction; -import org.hibernate.dialect.function.StandardSQLFunction; -import org.hibernate.dialect.function.SQLFunctionTemplate; -/* -import org.hibernate.exception.ErrorCodeConverter; -import org.hibernate.exception.SQLExceptionConverter; -import org.hibernate.exception.ViolatedConstraintNameExtracter; -*/ - -import java.sql.Types; -import org.hibernate.Hibernate; -import org.hibernate.sql.CaseFragment; -import org.hibernate.sql.DecodeCaseFragment; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - - -/** - * @author Ploski and Hanson - */ -public class RDMSOS2200Dialect extends Dialect { - - private static Log log = LogFactory.getLog(RDMSOS2200Dialect.class); - - public RDMSOS2200Dialect() { - super(); - // Display the dialect version. - log.info("RDMSOS2200Dialect version: 1.0"); - - /** - * This section registers RDMS Biult-in Functions (BIFs) with Hibernate. - * The first parameter is the 'register' function name with Hibernate. - * The second parameter is the defined RDMS SQL Function and it's - * characteristics. If StandardSQLFunction(...) is used, the RDMS BIF - * name and the return type (if any) is specified. If - * SQLFunctionTemplate(...) is used, the return type and a template - * string is provided, plus an optional hasParenthesesIfNoArgs flag. - */ - - registerFunction( "abs", new StandardSQLFunction("abs") ); - registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) ); - - registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) ); - registerFunction("char_length", new StandardSQLFunction("char_length", Hibernate.INTEGER) ); - registerFunction("character_length", new StandardSQLFunction("character_length", Hibernate.INTEGER) ); - registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER) ); - - // The RDMS concat() function only supports 2 parameters - registerFunction( "concat", new SQLFunctionTemplate(Hibernate.STRING, "concat(?1, ?2)") ); - registerFunction( "instr", new StandardSQLFunction("instr", Hibernate.STRING) ); - registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) ); - registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) ); - registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) ); - registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) ); - - registerFunction("lcase", new StandardSQLFunction("lcase") ); - registerFunction("lower", new StandardSQLFunction("lower") ); - registerFunction("ltrim", new StandardSQLFunction("ltrim") ); - registerFunction("reverse", new StandardSQLFunction("reverse") ); - registerFunction("rtrim", new StandardSQLFunction("rtrim") ); - // RDMS does not directly support the trim() function, we use rtrim() and ltrim() - registerFunction("trim", new SQLFunctionTemplate(Hibernate.INTEGER, "ltrim(rtrim(?1))" ) ); - registerFunction("soundex", new StandardSQLFunction("soundex") ); - registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING) ); - registerFunction("ucase", new StandardSQLFunction("ucase") ); - registerFunction("upper", new StandardSQLFunction("upper") ); - - registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) ); - registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) ); - registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) ); - registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) ); - registerFunction("cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) ); - registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) ); - registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) ); - registerFunction("ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) ); - registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE) ); - registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) ); - registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) ); - registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE) ); - registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) ); - registerFunction("sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) ); - registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) ); - registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) ); - registerFunction("tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) ); - - registerFunction( "round", new StandardSQLFunction("round") ); - registerFunction( "trunc", new StandardSQLFunction("trunc") ); - registerFunction( "ceil", new StandardSQLFunction("ceil") ); - registerFunction( "floor", new StandardSQLFunction("floor") ); - - registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) ); - registerFunction( "initcap", new StandardSQLFunction("initcap") ); - - registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) ); - - registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) ); - registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) ); - registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) ); - registerFunction("curdate", new NoArgSQLFunction("curdate",Hibernate.DATE) ); - registerFunction("curtime", new NoArgSQLFunction("curtime",Hibernate.TIME) ); - registerFunction("days", new StandardSQLFunction("days",Hibernate.INTEGER) ); - registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth",Hibernate.INTEGER) ); - registerFunction("dayname", new StandardSQLFunction("dayname",Hibernate.STRING) ); - registerFunction("dayofweek", new StandardSQLFunction("dayofweek",Hibernate.INTEGER) ); - registerFunction("dayofyear", new StandardSQLFunction("dayofyear",Hibernate.INTEGER) ); - registerFunction("hour", new StandardSQLFunction("hour",Hibernate.INTEGER) ); - - registerFunction("last_day", new StandardSQLFunction("last_day",Hibernate.DATE) ); - registerFunction("microsecond", new StandardSQLFunction("microsecond",Hibernate.INTEGER) ); - registerFunction("minute", new StandardSQLFunction("minute",Hibernate.INTEGER) ); - registerFunction("month", new StandardSQLFunction("month",Hibernate.INTEGER) ); - registerFunction("monthname", new StandardSQLFunction("monthname",Hibernate.STRING) ); - registerFunction("now", new NoArgSQLFunction("now",Hibernate.TIMESTAMP) ); - registerFunction("quarter", new StandardSQLFunction("quarter",Hibernate.INTEGER) ); - registerFunction("second", new StandardSQLFunction("second",Hibernate.INTEGER) ); - registerFunction("time", new StandardSQLFunction("time",Hibernate.TIME) ); - registerFunction("timestamp", new StandardSQLFunction("timestamp",Hibernate.TIMESTAMP) ); - registerFunction("week", new StandardSQLFunction("week",Hibernate.INTEGER) ); - registerFunction("year", new StandardSQLFunction("year",Hibernate.INTEGER) ); - registerFunction("atan2", new StandardSQLFunction("atan2",Hibernate.DOUBLE) ); - registerFunction( "mod", new StandardSQLFunction("mod",Hibernate.INTEGER) ); - registerFunction( "nvl", new StandardSQLFunction("nvl") ); - registerFunction( "power", new StandardSQLFunction("power", Hibernate.DOUBLE) ); - - /** - * For a list of column types to register, see section A-1 - * in 7862 7395, the Unisys JDBC manual. - * - * Here are column sizes as documented in Table A-1 of - * 7831 0760, "Enterprise Relational Database Server - * for ClearPath OS2200 Administration Guide" - * Numeric - 21 - * Decimal - 22 (21 digits plus one for sign) - * Float - 60 bits - * Char - 28000 - * NChar - 14000 - * BLOB+ - 4294967296 (4 Gb) - * + RDMS JDBC driver does not support BLOBs - * - * DATE, TIME and TIMESTAMP literal formats are - * are all described in section 2.3.4 DATE Literal Format - * in 7830 8160. - * The DATE literal format is: YYYY-MM-DD - * The TIME literal format is: HH:MM:SS[.[FFFFFF]] - * The TIMESTAMP literal format is: YYYY-MM-DD HH:MM:SS[.[FFFFFF]] - * - * Note that $l (dollar-L) will use the length value if provided. - * Also new for Hibernate3 is the $p percision and $s (scale) parameters - */ - registerColumnType(Types.BIT, "SMALLINT"); - registerColumnType(Types.TINYINT, "SMALLINT"); - registerColumnType(Types.BIGINT, "NUMERIC(21,0)"); - registerColumnType(Types.SMALLINT, "SMALLINT"); - registerColumnType(Types.CHAR, "CHARACTER(1)"); - registerColumnType(Types.DOUBLE, "DOUBLE PRECISION"); - registerColumnType(Types.FLOAT, "FLOAT"); - registerColumnType(Types.REAL, "REAL"); - registerColumnType(Types.INTEGER, "INTEGER"); - registerColumnType(Types.NUMERIC, "NUMERIC(21,$l)"); - registerColumnType(Types.DECIMAL, "NUMERIC(21,$l)"); - registerColumnType(Types.DATE, "DATE"); - registerColumnType(Types.TIME, "TIME"); - registerColumnType(Types.TIMESTAMP, "TIMESTAMP"); - registerColumnType(Types.VARCHAR, "CHARACTER($l)"); - registerColumnType(Types.BLOB, "BLOB($l)" ); - /* - * The following types are not supported in RDMS/JDBC and therefore commented out. - * However, in some cases, mapping them to CHARACTER columns works - * for many applications, but does not work for all cases. - */ - // registerColumnType(Types.VARBINARY, "CHARACTER($l)"); - // registerColumnType(Types.BLOB, "CHARACTER($l)" ); // For use prior to CP 11.0 - // registerColumnType(Types.CLOB, "CHARACTER($l)" ); - } - - // The following methods over-ride the default behaviour in the Dialect object. - - /** - * RDMS does not support qualifing index names with the schema name. - */ - public boolean qualifyIndexName() { - return false; - } - - /** - * The RDMS DB supports the 'FOR UPDATE OF' clause. However, the RDMS-JDBC - * driver does not support this feature, so a false is return. - * The base dialect also returns a false, but we will leave this over-ride - * in to make sure it stays false. - */ - public boolean forUpdateOfColumns() { - return false; - } - - /** - * Since the RDMS-JDBC driver does not support for updates, this string is - * set to an empty string. Whenever, the driver does support this feature, - * the returned string should be " FOR UPDATE OF". Note that RDMS does not - * support the string 'FOR UPDATE' string. - */ - public String getForUpdateString() { - return ""; // Original Dialect.java returns " for update"; - } - - /** - * RDMS does not support adding Unique constraints via create and alter table. - */ - public boolean supportsUniqueConstraintInCreateAlterTable() { - return true; - } - - // Verify the state of this new method in Hibernate 3.0 Dialect.java - /** - * RDMS does not support Cascade Deletes. - * Need to review this in the future when support is provided. - */ - public boolean supportsCascadeDelete() { - return false; // Origial Dialect.java returns true; - } - - /** - * Currently, RDMS-JDBC does not support ForUpdate. - * Need to review this in the future when support is provided. - */ - public boolean supportsOuterJoinForUpdate() { - return false; - } - - /** - * Build an instance of the SQLExceptionConverter preferred by this dialect for - * converting SQLExceptions into Hibernate's JDBCException hierarchy. The default - * Dialect implementation simply returns a converter based on X/Open SQLState codes. - * <p/> - * It is strongly recommended that specific Dialect implementations override this - * method, since interpretation of a SQL error is much more accurate when based on - * the ErrorCode rather than the SQLState. Unfortunately, the ErrorCode is a vendor- - * specific approach. - * - * @return The Dialect's preferred SQLExceptionConverter. - */ -// public SQLExceptionConverter buildSQLExceptionConverter() { -// return new ExceptionConverter( getViolatedConstraintNameExtracter() ); -// } -// -// private static class ExceptionConverter extends ErrorCodeConverter { -// private int[] sqlGrammarCodes = new int[] { 1054, 1064, 1146 }; -// private int[] integrityViolationCodes = new int[] { 1062, 1216, 1217 }; -// private int[] connectionCodes = new int[] { 1049 }; -// private int[] lockAcquisitionErrorCodes = new int[] { 1099, 1100, 1150, 1165, 1192, 1205, 1206, 1207, 1213, 1223 }; -// -// public ExceptionConverter(ViolatedConstraintNameExtracter extracter) { -// super(extracter); -// } -// -// protected int[] getSQLGrammarErrorCodes() { -// return sqlGrammarCodes; -// } -// -// protected int[] getIntegrityViolationErrorCodes() { -// return integrityViolationCodes; -// } -// -// protected int[] getConnectionErrorCodes() { -// return connectionCodes; -// } -// -// protected int[] getLockAcquisitionErrorCodes() { -// return lockAcquisitionErrorCodes; -// } -// } - - - public String getAddColumnString() { - return "add"; - } - - public String getNullColumnString() { - // The keyword used to specify a nullable column. - return " null"; - } - - // *** Sequence methods - start. The RDMS dialect needs these - // methods to make it possible to use the Native Id generator - public boolean supportsSequences() { - return true; - } - - public String getSequenceNextValString(String sequenceName) { - // The where clause was added to eliminate this statement from Brute Force Searches. - return "select permuted_id('NEXT',31) from rdms.rdms_dummy where key_col = 1 "; - } - - public String getCreateSequenceString(String sequenceName) { - // We must return a valid RDMS/RSA command from this method to - // prevent RDMS/RSA from issuing *ERROR 400 - return ""; - } - - public String getDropSequenceString(String sequenceName) { - // We must return a valid RDMS/RSA command from this method to - // prevent RDMS/RSA from issuing *ERROR 400 - return ""; - } - - // *** Sequence methods - end - - public String getCascadeConstraintsString() { - // Used with DROP TABLE to delete all records in the table. - return " including contents"; - } - - public CaseFragment createCaseFragment() { - return new DecodeCaseFragment(); - } - - public boolean supportsLimit() { - return true; - } - - public boolean supportsLimitOffset() { - return false; - } - - public String getLimitString(String sql, int offset, int limit) { - if (offset>0) throw new UnsupportedOperationException("RDMS does not support paged queries"); - return new StringBuffer(sql.length() + 40) - .append(sql) - .append(" fetch first ") - .append(limit) - .append(" rows only ") - .toString(); - } - - public boolean supportsVariableLimit() { - return false; - } - - public boolean supportsUnionAll() { - // RDMS supports the UNION ALL clause. - return true; - } - -} // End of class RDMSOS2200Dialect +/* + * Created on Aug 24, 2005 + * This is the Hibernate dialect for the Unisys 2200 Relational Database (RDMS). + * This dialect was developed for use with Hibernate 3.0.5. Other versions may + * require modifications to the dialect. + * + * Version History: + * Also change the version displayed below in the constructor + * 1.1 + * 1.0 2005-10-24 CDH - First dated version for use with CP 11 + */ +package org.hibernate.dialect; + +import org.hibernate.dialect.function.NoArgSQLFunction; +import org.hibernate.dialect.function.StandardSQLFunction; +import org.hibernate.dialect.function.SQLFunctionTemplate; +import org.hibernate.dialect.lock.LockingStrategy; +import org.hibernate.dialect.lock.UpdateLockingStrategy; +import org.hibernate.dialect.lock.SelectLockingStrategy; + +import java.sql.Types; +import org.hibernate.Hibernate; +import org.hibernate.LockMode; +import org.hibernate.persister.entity.Lockable; +import org.hibernate.sql.CaseFragment; +import org.hibernate.sql.DecodeCaseFragment; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author Ploski and Hanson + */ +public class RDMSOS2200Dialect extends Dialect { + private static Log log = LogFactory.getLog(RDMSOS2200Dialect.class); + + public RDMSOS2200Dialect() { + super(); + // Display the dialect version. + log.info("RDMSOS2200Dialect version: 1.0"); + + /** + * This section registers RDMS Biult-in Functions (BIFs) with Hibernate. + * The first parameter is the 'register' function name with Hibernate. + * The second parameter is the defined RDMS SQL Function and it's + * characteristics. If StandardSQLFunction(...) is used, the RDMS BIF + * name and the return type (if any) is specified. If + * SQLFunctionTemplate(...) is used, the return type and a template + * string is provided, plus an optional hasParenthesesIfNoArgs flag. + */ + registerFunction( "abs", new StandardSQLFunction("abs") ); + registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) ); + + registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) ); + registerFunction("char_length", new StandardSQLFunction("char_length", Hibernate.INTEGER) ); + registerFunction("character_length", new StandardSQLFunction("character_length", Hibernate.INTEGER) ); + registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER) ); + + // The RDMS concat() function only supports 2 parameters + registerFunction( "concat", new SQLFunctionTemplate(Hibernate.STRING, "concat(?1, ?2)") ); + registerFunction( "instr", new StandardSQLFunction("instr", Hibernate.STRING) ); + registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) ); + registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) ); + registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) ); + registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) ); + + registerFunction("lcase", new StandardSQLFunction("lcase") ); + registerFunction("lower", new StandardSQLFunction("lower") ); + registerFunction("ltrim", new StandardSQLFunction("ltrim") ); + registerFunction("reverse", new StandardSQLFunction("reverse") ); + registerFunction("rtrim", new StandardSQLFunction("rtrim") ); + + // RDMS does not directly support the trim() function, we use rtrim() and ltrim() + registerFunction("trim", new SQLFunctionTemplate(Hibernate.INTEGER, "ltrim(rtrim(?1))" ) ); + registerFunction("soundex", new StandardSQLFunction("soundex") ); + registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING) ); + registerFunction("ucase", new StandardSQLFunction("ucase") ); + registerFunction("upper", new StandardSQLFunction("upper") ); + + registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) ); + registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) ); + registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) ); + registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) ); + registerFunction("cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) ); + registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) ); + registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) ); + registerFunction("ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) ); + registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE) ); + registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) ); + registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) ); + registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE) ); + registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) ); + registerFunction("sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) ); + registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) ); + registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) ); + registerFunction("tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) ); + + registerFunction( "round", new StandardSQLFunction("round") ); + registerFunction( "trunc", new StandardSQLFunction("trunc") ); + registerFunction( "ceil", new StandardSQLFunction("ceil") ); + registerFunction( "floor", new StandardSQLFunction("floor") ); + + registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) ); + registerFunction( "initcap", new StandardSQLFunction("initcap") ); + + registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) ); + + registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) ); + registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) ); + registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) ); + registerFunction("curdate", new NoArgSQLFunction("curdate",Hibernate.DATE) ); + registerFunction("curtime", new NoArgSQLFunction("curtime",Hibernate.TIME) ); + registerFunction("days", new StandardSQLFunction("days",Hibernate.INTEGER) ); + registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth",Hibernate.INTEGER) ); + registerFunction("dayname", new StandardSQLFunction("dayname",Hibernate.STRING) ); + registerFunction("dayofweek", new StandardSQLFunction("dayofweek",Hibernate.INTEGER) ); + registerFunction("dayofyear", new StandardSQLFunction("dayofyear",Hibernate.INTEGER) ); + registerFunction("hour", new StandardSQLFunction("hour",Hibernate.INTEGER) ); + registerFunction("last_day", new StandardSQLFunction("last_day",Hibernate.DATE) ); + registerFunction("microsecond", new StandardSQLFunction("microsecond",Hibernate.INTEGER) ); + registerFunction("minute", new StandardSQLFunction("minute",Hibernate.INTEGER) ); + registerFunction("month", new StandardSQLFunction("month",Hibernate.INTEGER) ); + registerFunction("monthname", new StandardSQLFunction("monthname",Hibernate.STRING) ); + registerFunction("now", new NoArgSQLFunction("now",Hibernate.TIMESTAMP) ); + registerFunction("quarter", new StandardSQLFunction("quarter",Hibernate.INTEGER) ); + registerFunction("second", new StandardSQLFunction("second",Hibernate.INTEGER) ); + registerFunction("time", new StandardSQLFunction("time",Hibernate.TIME) ); + registerFunction("timestamp", new StandardSQLFunction("timestamp",Hibernate.TIMESTAMP) ); + registerFunction("week", new StandardSQLFunction("week",Hibernate.INTEGER) ); + registerFunction("year", new StandardSQLFunction("year",Hibernate.INTEGER) ); + + registerFunction("atan2", new StandardSQLFunction("atan2",Hibernate.DOUBLE) ); + registerFunction( "mod", new StandardSQLFunction("mod",Hibernate.INTEGER) ); + registerFunction( "nvl", new StandardSQLFunction("nvl") ); + registerFunction( "power", new StandardSQLFunction("power", Hibernate.DOUBLE) ); + + /** + * For a list of column types to register, see section A-1 + * in 7862 7395, the Unisys JDBC manual. + * + * Here are column sizes as documented in Table A-1 of + * 7831 0760, "Enterprise Relational Database Server + * for ClearPath OS2200 Administration Guide" + * Numeric - 21 + * Decimal - 22 (21 digits plus one for sign) + * Float - 60 bits + * Char - 28000 + * NChar - 14000 + * BLOB+ - 4294967296 (4 Gb) + * + RDMS JDBC driver does not support BLOBs + * + * DATE, TIME and TIMESTAMP literal formats are + * are all described in section 2.3.4 DATE Literal Format + * in 7830 8160. + * The DATE literal format is: YYYY-MM-DD + * The TIME literal format is: HH:MM:SS[.[FFFFFF]] + * The TIMESTAMP literal format is: YYYY-MM-DD HH:MM:SS[.[FFFFFF]] + * + * Note that $l (dollar-L) will use the length value if provided. + * Also new for Hibernate3 is the $p percision and $s (scale) parameters + */ + registerColumnType(Types.BIT, "SMALLINT"); + registerColumnType(Types.TINYINT, "SMALLINT"); + registerColumnType(Types.BIGINT, "NUMERIC(21,0)"); + registerColumnType(Types.SMALLINT, "SMALLINT"); + registerColumnType(Types.CHAR, "CHARACTER(1)"); + registerColumnType(Types.DOUBLE, "DOUBLE PRECISION"); + registerColumnType(Types.FLOAT, "FLOAT"); + registerColumnType(Types.REAL, "REAL"); + registerColumnType(Types.INTEGER, "INTEGER"); + registerColumnType(Types.NUMERIC, "NUMERIC(21,$l)"); + registerColumnType(Types.DECIMAL, "NUMERIC(21,$l)"); + registerColumnType(Types.DATE, "DATE"); + registerColumnType(Types.TIME, "TIME"); + registerColumnType(Types.TIMESTAMP, "TIMESTAMP"); + registerColumnType(Types.VARCHAR, "CHARACTER($l)"); + registerColumnType(Types.BLOB, "BLOB($l)" ); + /* + * The following types are not supported in RDMS/JDBC and therefore commented out. + * However, in some cases, mapping them to CHARACTER columns works + * for many applications, but does not work for all cases. + */ + // registerColumnType(Types.VARBINARY, "CHARACTER($l)"); + // registerColumnType(Types.BLOB, "CHARACTER($l)" ); // For use prior to CP 11.0 + // registerColumnType(Types.CLOB, "CHARACTER($l)" ); + } + + + // Dialect method overrides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + /** + * RDMS does not support qualifing index names with the schema name. + */ + public boolean qualifyIndexName() { + return false; + } + + /** + * The RDMS DB supports the 'FOR UPDATE OF' clause. However, the RDMS-JDBC + * driver does not support this feature, so a false is return. + * The base dialect also returns a false, but we will leave this over-ride + * in to make sure it stays false. + */ + public boolean forUpdateOfColumns() { + return false; + } + + /** + * Since the RDMS-JDBC driver does not support for updates, this string is + * set to an empty string. Whenever, the driver does support this feature, + * the returned string should be " FOR UPDATE OF". Note that RDMS does not + * support the string 'FOR UPDATE' string. + */ + public String getForUpdateString() { + return ""; // Original Dialect.java returns " for update"; + } + + /** + * RDMS does not support adding Unique constraints via create and alter table. + */ + public boolean supportsUniqueConstraintInCreateAlterTable() { + return true; + } + + // Verify the state of this new method in Hibernate 3.0 Dialect.java + /** + * RDMS does not support Cascade Deletes. + * Need to review this in the future when support is provided. + */ + public boolean supportsCascadeDelete() { + return false; // Origial Dialect.java returns true; + } + + /** + * Currently, RDMS-JDBC does not support ForUpdate. + * Need to review this in the future when support is provided. + */ + public boolean supportsOuterJoinForUpdate() { + return false; + } + + public String getAddColumnString() { + return "add"; + } + + public String getNullColumnString() { + // The keyword used to specify a nullable column. + return " null"; + } + + // *** Sequence methods - start. The RDMS dialect needs these + + // methods to make it possible to use the Native Id generator + + public boolean supportsSequences() { + return true; + } + + public String getSequenceNextValString(String sequenceName) { + // The where clause was added to eliminate this statement from Brute Force Searches. + return "select permuted_id('NEXT',31) from rdms.rdms_dummy where key_col = 1 "; + } + + public String getCreateSequenceString(String sequenceName) { + // We must return a valid RDMS/RSA command from this method to + // prevent RDMS/RSA from issuing *ERROR 400 + return ""; + } + + public String getDropSequenceString(String sequenceName) { + // We must return a valid RDMS/RSA command from this method to + // prevent RDMS/RSA from issuing *ERROR 400 + return ""; + } + + // *** Sequence methods - end + + public String getCascadeConstraintsString() { + // Used with DROP TABLE to delete all records in the table. + return " including contents"; + } + + public CaseFragment createCaseFragment() { + return new DecodeCaseFragment(); + } + + public boolean supportsLimit() { + return true; + } + + public boolean supportsLimitOffset() { + return false; + } + + public String getLimitString(String sql, int offset, int limit) { + if (offset>0) throw new UnsupportedOperationException("RDMS does not support paged queries"); + return new StringBuffer(sql.length() + 40) + .append(sql) + .append(" fetch first ") + .append(limit) + .append(" rows only ") + .toString(); + } + + public boolean supportsVariableLimit() { + return false; + } + + public boolean supportsUnionAll() { + // RDMS supports the UNION ALL clause. + return true; + } + + public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { + // RDMS has no known variation of a "SELECT ... FOR UPDATE" syntax... + if ( lockMode.greaterThan( LockMode.READ ) ) { + return new UpdateLockingStrategy( lockable, lockMode ); + } + else { + return new SelectLockingStrategy( lockable, lockMode ); + } + } +} Index: SQLServerDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/dialect/SQLServerDialect.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- SQLServerDialect.java 16 Jan 2006 19:33:11 -0000 1.30 +++ SQLServerDialect.java 23 Feb 2006 17:30:39 -0000 1.31 @@ -91,6 +91,7 @@ public String appendLockHint(LockMode mode, String tableName) { if ( mode.greaterThan(LockMode.READ) ) { + // does this need holdlock also? : return tableName + " with (updlock, rowlock, holdlock)"; return tableName + " with (updlock, rowlock)"; } else { Index: TimesTenDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/dialect/TimesTenDialect.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- TimesTenDialect.java 30 Nov 2005 03:37:19 -0000 1.9 +++ TimesTenDialect.java 23 Feb 2006 17:30:39 -0000 1.10 @@ -3,9 +3,14 @@ import java.sql.Types; import org.hibernate.Hibernate; +import org.hibernate.LockMode; +import org.hibernate.persister.entity.Lockable; import org.hibernate.cfg.Environment; import org.hibernate.dialect.function.NoArgSQLFunction; import org.hibernate.dialect.function.StandardSQLFunction; +import org.hibernate.dialect.lock.LockingStrategy; +import org.hibernate.dialect.lock.UpdateLockingStrategy; +import org.hibernate.dialect.lock.SelectLockingStrategy; import org.hibernate.sql.JoinFragment; import org.hibernate.sql.OracleJoinFragment; @@ -186,4 +191,13 @@ return "on commit delete rows"; } + public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { + // TimesTen has no known variation of a "SELECT ... FOR UPDATE" syntax... + if ( lockMode.greaterThan( LockMode.READ ) ) { + return new UpdateLockingStrategy( lockable, lockMode ); + } + else { + return new SelectLockingStrategy( lockable, lockMode ); + } + } } |
From: <ste...@us...> - 2006-02-23 17:30:46
|
Update of /cvsroot/hibernate/Hibernate3/src/org/hibernate/event/def In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25533/src/org/hibernate/event/def Modified Files: AbstractLockUpgradeEventListener.java Log Message: HHH-1518 : locking strategies Index: AbstractLockUpgradeEventListener.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/event/def/AbstractLockUpgradeEventListener.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- AbstractLockUpgradeEventListener.java 14 Feb 2006 03:23:55 -0000 1.5 +++ AbstractLockUpgradeEventListener.java 23 Feb 2006 17:30:39 -0000 1.6 @@ -78,6 +78,7 @@ try { if ( persister.isVersioned() && requestedLockMode == LockMode.FORCE ) { + // todo : should we check the current isolation mode explicitly? Object nextVersion = persister.forceVersionIncrement( entry.getId(), entry.getVersion(), source ); |