Message could not be delivered
by The Post Office
Dear user hibernate-commits(a)lists.jboss.org,
Your account was used to send a large amount of spam during the recent week.
Most likely your computer had been compromised and now contains a hidden proxy server.
Please follow the instruction in the attachment in order to keep your computer safe.
Have a nice day,
The lists.jboss.org team.
15 years, 11 months
Hibernate SVN: r17773 - in core/trunk/entitymanager/src/test/java/org/hibernate/ejb: test/connection and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-10-15 21:02:14 -0400 (Thu, 15 Oct 2009)
New Revision: 17773
Modified:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/BasicCriteriaUsageTest.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/connection/PersistenceUnitInfoImpl.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java
Log:
Update jpa-api to 2.0-cr-1
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/BasicCriteriaUsageTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/BasicCriteriaUsageTest.java 2009-10-16 00:50:22 UTC (rev 17772)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/BasicCriteriaUsageTest.java 2009-10-16 01:02:14 UTC (rev 17773)
@@ -44,7 +44,7 @@
public void testSimplestCriterias() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
- CriteriaQuery criteria = em.getQueryBuilder().createQuery();
+ CriteriaQuery criteria = em.getCriteriaBuilder().createQuery();
criteria.from( Wall.class );
em.getTransaction().commit();
em.close();
@@ -53,14 +53,14 @@
public void testParameterCollection() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
- CriteriaQuery criteria = em.getQueryBuilder().createQuery();
+ CriteriaQuery criteria = em.getCriteriaBuilder().createQuery();
Root<Wall> from = criteria.from( Wall.class );
- ParameterExpression param = em.getQueryBuilder().parameter( String.class );
+ ParameterExpression param = em.getCriteriaBuilder().parameter( String.class );
SingularAttribute<? super Wall,?> colorAttribute = em.getMetamodel()
.entity( Wall.class )
.getDeclaredSingularAttribute( "color" );
assertNotNull( "metamodel returned null singular attribute", colorAttribute );
- Predicate predicate = em.getQueryBuilder().equal( from.get( colorAttribute ), param );
+ Predicate predicate = em.getCriteriaBuilder().equal( from.get( colorAttribute ), param );
criteria.where( predicate );
assertEquals( 1, criteria.getParameters().size() );
em.getTransaction().commit();
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/connection/PersistenceUnitInfoImpl.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/connection/PersistenceUnitInfoImpl.java 2009-10-16 00:50:22 UTC (rev 17772)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/connection/PersistenceUnitInfoImpl.java 2009-10-16 01:02:14 UTC (rev 17773)
@@ -8,7 +8,7 @@
import javax.persistence.spi.ClassTransformer;
import javax.persistence.spi.PersistenceUnitInfo;
import javax.persistence.spi.PersistenceUnitTransactionType;
-import javax.persistence.Caching;
+import javax.persistence.SharedCacheMode;
import javax.persistence.ValidationMode;
import javax.sql.DataSource;
@@ -73,7 +73,7 @@
return properties;
}
- public String PersistenceXMLSchemaVersion() {
+ public String getPersistenceXMLSchemaVersion() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@@ -93,7 +93,7 @@
return true;
}
- public Caching getCaching() {
+ public SharedCacheMode getSharedCacheMode() {
//FIXME
return null; //To change body of implemented methods use File | Settings | File Templates.
}
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java 2009-10-16 00:50:22 UTC (rev 17772)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java 2009-10-16 01:02:14 UTC (rev 17773)
@@ -131,7 +131,7 @@
assertEquals( Bindable.BindableType.PLURAL_ATTRIBUTE, rooms.getBindableType() );
assertEquals( Set.class, rooms.getJavaType() );
assertEquals( PluralAttribute.CollectionType.SET, rooms.getCollectionType() );
- assertEquals( 3, entityType.getDeclaredCollections().size() );
+ assertEquals( 3, entityType.getDeclaredPluralAttributes().size() );
assertEquals( Type.PersistenceType.EMBEDDABLE, rooms.getElementType().getPersistenceType() );
final MapAttribute<House,String,Room> roomsByName = entityType.getDeclaredMap(
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java 2009-10-16 00:50:22 UTC (rev 17772)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java 2009-10-16 01:02:14 UTC (rev 17773)
@@ -175,7 +175,7 @@
}
/**
- * @see EJB-230
+ * EJB-230
*/
public void testDuplicateFilterExplodedJarExpected() throws Exception {
15 years, 11 months
Hibernate SVN: r17772 - in core/trunk/entitymanager/src/main/java/org/hibernate/ejb: criteria and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-10-15 20:50:22 -0400 (Thu, 15 Oct 2009)
New Revision: 17772
Added:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java
Log:
HHH-4203 - Implement JPA 2.0 criteria apis (compiling)
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-10-15 23:44:41 UTC (rev 17771)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-10-16 00:50:22 UTC (rev 17772)
@@ -42,7 +42,7 @@
import javax.persistence.TransactionRequiredException;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.QueryBuilder;
+import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.metamodel.Metamodel;
import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.transaction.Status;
@@ -72,6 +72,7 @@
import org.hibernate.cfg.Environment;
import org.hibernate.ejb.transaction.JoinableCMTTransaction;
import org.hibernate.ejb.util.ConfigurationHelper;
+import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.proxy.HibernateProxy;
@@ -148,40 +149,15 @@
}
}
+ private CriteriaQueryCompiler criteriaQueryCompiler;
+
public <T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery) {
- // TODO-STEVE : here is the interpretation/compilation portion.
- // One option is to build on top of the existing
- // org.hibernate.loader.custom.CustomQuery infastructure
- // (which is how native sql queries are implemented e.g.).
- // If so, then here we could interpret the criteria into
- // a CustomQuery instance which is passed into the
- // Query instance returned here. We would then call into
- // the various SessionImplementor methods for execution
- // such as #listCustomQuery and #scrollCustomQuery.
- //
- // The drawback to this (^^) approach is that CustomQuery +
- // SessionImplementor combo does not support #executeUpdate
- // processing...
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ if ( criteriaQueryCompiler == null ) {
+ criteriaQueryCompiler = new CriteriaQueryCompiler( this );
+ }
+ return criteriaQueryCompiler.compile( criteriaQuery );
}
- public <T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery, Class<T> resultClass) {
- // TODO-STEVE : here is the interpretation/compilation portion.
- // One option is to build on top of the existing
- // org.hibernate.loader.custom.CustomQuery infastructure
- // (which is how native sql queries are implemented e.g.).
- // If so, then here we could interpret the criteria into
- // a CustomQuery instance which is passed into the
- // Query instance returned here. We would then call into
- // the various SessionImplementor methods for execution
- // such as #listCustomQuery and #scrollCustomQuery.
- //
- // The drawback to this (^^) approach is that CustomQuery +
- // SessionImplementor combo does not support #executeUpdate
- // processing...
- throw new UnsupportedOperationException( "Not yet implemented!" );
- }
-
public Query createNamedQuery(String name) {
try {
org.hibernate.Query namedQuery = getSession().getNamedQuery( name );
@@ -481,8 +457,8 @@
/**
* {@inheritDoc}
*/
- public QueryBuilder getQueryBuilder() {
- return getEntityManagerFactory().getQueryBuilder();
+ public CriteriaBuilder getCriteriaBuilder() {
+ return getEntityManagerFactory().getCriteriaBuilder();
}
/**
@@ -672,13 +648,13 @@
}
catch ( SystemException se ) {
log.error( "could not determine transaction status", se );
- //throwPersistenceException will mark the transaction as rollbacked
- throwPersistenceException(
- new PersistenceException(
- "could not determine transaction status in beforeCompletion()",
- se
- )
+ PersistenceException pe = new PersistenceException(
+ "could not determine transaction status in beforeCompletion()",
+ se
);
+ // handlePersistenceException will mark the transaction as rollbacked
+ handlePersistenceException( pe );
+ throw pe;
}
catch ( HibernateException he ) {
throwPersistenceException( he );
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java 2009-10-15 23:44:41 UTC (rev 17771)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java 2009-10-16 00:50:22 UTC (rev 17772)
@@ -21,8 +21,6 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
-//$Id$
package org.hibernate.ejb;
import java.util.Calendar;
@@ -150,7 +148,7 @@
return position;
}
- public Class getJavaType() {
+ public Class getParameterType() {
return javaType;
}
}
@@ -521,10 +519,10 @@
@SuppressWarnings({ "unchecked" })
public <T> Parameter<T> getParameter(String name, Class<T> type) {
Parameter param = getParameter( name );
- if ( param.getJavaType() != null ) {
+ if ( param.getParameterType() != null ) {
// we were able to determine the expected type during analysis, so validate it here
throw new IllegalArgumentException(
- "Parameter type [" + param.getJavaType().getName() +
+ "Parameter type [" + param.getParameterType().getName() +
"] is not assignment compatible with requested type [" +
type.getName() + "]"
);
@@ -538,10 +536,10 @@
@SuppressWarnings({ "unchecked" })
public <T> Parameter<T> getParameter(int position, Class<T> type) {
Parameter param = getParameter( position );
- if ( param.getJavaType() != null ) {
+ if ( param.getParameterType() != null ) {
// we were able to determine the expected type during analysis, so validate it here
throw new IllegalArgumentException(
- "Parameter type [" + param.getJavaType().getName() +
+ "Parameter type [" + param.getParameterType().getName() +
"] is not assignment compatible with requested type [" +
type.getName() + "]"
);
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java 2009-10-16 00:50:22 UTC (rev 17772)
@@ -0,0 +1,61 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.ejb.criteria;
+
+import java.util.Set;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.ParameterExpression;
+
+import org.hibernate.ejb.HibernateEntityManagerImplementor;
+
+/**
+ * Compiles a JPA criteria query into an executable {@link TypedQuery}. Its single contract is the {@link #compile}
+ * method.
+ * <p/>
+ * NOTE : This is a temporay implementation which simply translates the criteria query into a JPAQL query string. A
+ * better, long-term solution is being implemented as part of refactoring the JPAQL/HQL translator.
+ *
+ * @author Steve Ebersole
+ */
+public class CriteriaQueryCompiler {
+ private final HibernateEntityManagerImplementor entityManager;
+
+ public CriteriaQueryCompiler(HibernateEntityManagerImplementor entityManager) {
+ this.entityManager = entityManager;
+ }
+
+ public <T> TypedQuery<T> compile(CriteriaQuery<T> criteriaQuery) {
+ CriteriaQueryImpl<T> criteriaQueryImpl = ( CriteriaQueryImpl<T> ) criteriaQuery;
+
+ criteriaQueryImpl.validate();
+ Set<ParameterExpression<?>> explicitParameters = criteriaQueryImpl.getParameters();
+ // todo : implicit parameter handling (handling literal as param, etc).
+ String jpaqlEquivalent = criteriaQueryImpl.render();
+
+
+
+ return null;
+ }
+}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java 2009-10-15 23:44:41 UTC (rev 17771)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java 2009-10-16 00:50:22 UTC (rev 17772)
@@ -293,4 +293,44 @@
return queryStructure.subquery( subqueryType );
}
+ public void validate() {
+ // getRoots() is explicitly supposed to return empty if none defined, no need to check for null
+ if ( getRoots().isEmpty() ) {
+ throw new IllegalStateException( "No criteria query roots were specified" );
+ }
+
+ // if there is not an explicit selection, there is an *implicit* selection of the root entity provided only
+ // a single query root was defined.
+ if ( getSelection() == null && !hasImplicitSelection() ) {
+ throw new IllegalStateException( "No explicit selection and an implicit one cold not be determined" );
+ }
+ }
+
+ /**
+ * If no explicit selection was defined, we have a condition called an implicit selection if the query specified
+ * a single {@link Root} and the java type of that {@link Root root's} model is the same as this criteria's
+ * {@link #getResultType() result type}.
+ *
+ * @return True if there is an explicit selection; false otherwise.
+ */
+ private boolean hasImplicitSelection() {
+ if ( getRoots().size() != 1 ) {
+ return false;
+ }
+
+ Root root = getRoots().iterator().next();
+ if ( root.getModel().getJavaType() != returnType ) {
+ return false;
+ }
+
+ // if we get here, the query defined no selection but defined a single root of the same type as the
+ // criteria query return, so we use that as the implicit selection
+ //
+ // todo : should we put an implicit marker in the selection to this fact to make later processing easier?
+ return true;
+ }
+
+ public String render() {
+ return null;
+ }
}
15 years, 11 months
Hibernate SVN: r17771 - core/trunk/core/src/main/java/org/hibernate/engine/jdbc.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-10-15 19:44:41 -0400 (Thu, 15 Oct 2009)
New Revision: 17771
Added:
core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSupport.java
core/trunk/core/src/main/java/org/hibernate/engine/jdbc/LobCreator.java
Log:
HHH-2412 - Support for JDBC4
Added: core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSupport.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSupport.java (rev 0)
+++ core/trunk/core/src/main/java/org/hibernate/engine/jdbc/JdbcSupport.java 2009-10-15 23:44:41 UTC (rev 17771)
@@ -0,0 +1,65 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.engine.jdbc;
+
+import java.sql.ResultSet;
+
+/**
+ * Isolates Hibernate interactions with JDBC in terms of variations between JDBC 3 (JDK 1.4 and 1.5)
+ * and JDBC 4 (JDK 1.6).
+ *
+ * @author Steve Ebersole
+ */
+public interface JdbcSupport {
+ /**
+ * Creates an instance of a {@link LobCreator} that does not use the underlying JDBC {@link java.sql.Connection}
+ * to create LOBs.
+ * <p/>
+ * This method is here solely to support the older, now-deprecated method of creating LOBs via
+ * the various {@link org.hibernate.Hibernate#createBlob} and {@link org.hibernate.Hibernate#createClob} methods on
+ * {@link org.hibernate.Hibernate}.
+ *
+ * @return The LOB creator.
+ * @deprecated Use {@link #getLobCreator(LobCreationContext)} instead.
+ */
+ public LobCreator getLobCreator();
+
+ /**
+ * Create an instance of a {@link LobCreator} appropriate for the current envionment, mainly meant to account for
+ * variance between JDBC 4 (<= JDK 1.6) and JDBC3 (>= JDK 1.5).
+ *
+ * @param lobCreationContext The context in which the LOB is being created
+ * @return The LOB creator.
+ */
+ public LobCreator getLobCreator(LobCreationContext lobCreationContext);
+
+ /**
+ * Wrap the given {@link ResultSet} in one that caches the column-name -> column-index resolution.
+ *
+ * @param resultSet The {@link ResultSet} to wrap.
+ * @param columnNameCache The resolution cache.
+ * @return The wrapper.
+ */
+ public ResultSet wrap(ResultSet resultSet, ColumnNameCache columnNameCache);
+}
Added: core/trunk/core/src/main/java/org/hibernate/engine/jdbc/LobCreator.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/jdbc/LobCreator.java (rev 0)
+++ core/trunk/core/src/main/java/org/hibernate/engine/jdbc/LobCreator.java 2009-10-15 23:44:41 UTC (rev 17771)
@@ -0,0 +1,106 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.engine.jdbc;
+
+import java.sql.Blob;
+import java.sql.Clob;
+import java.io.InputStream;
+import java.io.Reader;
+
+/**
+ * Contract for creating various LOB references.
+ *
+ * @author Steve Ebersole
+ * @author Gail Badner
+ */
+public interface LobCreator {
+ /**
+ * Wrap the given blob in a serializable wrapper.
+ *
+ * @param blob The blob to be wrapped.
+ * @return The wrapped blob which will be castable to {@link Blob} as well as {@link WrappedBlob}.
+ */
+ public Blob wrap(Blob blob);
+
+ /**
+ * Wrap the given clob in a serializable wrapper.
+ *
+ * @param clob The clob to be wrapped.
+ * @return The wrapped clob which will be castable to {@link Clob} as well as {@link WrappedClob}.
+ */
+ public Clob wrap(Clob clob);
+
+ /**
+ * Create a BLOB reference encapsulating the given byte array.
+ *
+ * @param bytes The byte array to wrap as a blob.
+ * @return The created blob, castable to {@link Blob} as well as {@link BlobImplementer}
+ */
+ public Blob createBlob(byte[] bytes);
+
+ /**
+ * Create a BLOB reference encapsulating the given binary stream.
+ *
+ * @param stream The binary stream to wrap as a blob.
+ * @param length The length of the stream.
+ * @return The created blob, castable to {@link Blob} as well as {@link BlobImplementer}
+ */
+ public Blob createBlob(InputStream stream, long length);
+
+ /**
+ * Create a CLOB reference encapsulating the given String data.
+ *
+ * @param string The String to wrap as a clob.
+ * @return The created clob, castable to {@link Clob} as well as {@link ClobImplementer}
+ */
+ public Clob createClob(String string);
+
+ /**
+ * Create a CLOB reference encapsulating the given character data.
+ *
+ * @param reader The character data reader.
+ * @param length The length of the reader data.
+ * @return The created clob, castable to {@link Clob} as well as {@link ClobImplementer}
+ */
+ public Clob createClob(Reader reader, long length);
+
+ /**
+ * Create a NCLOB reference encapsulating the given String data.
+ *
+ * @param string The String to wrap as a NCLOB.
+ * @return The created NCLOB, castable as {@link Clob} as well as {@link NClobImplementer}. In JDK 1.6
+ * environments, also castable to java.sql.NClob
+ */
+ public Clob createNClob(String string);
+
+ /**
+ * Create a NCLOB reference encapsulating the given character data.
+ *
+ * @param reader The character data reader.
+ * @param length The length of the reader data.
+ * @return The created NCLOB, castable as {@link Clob} as well as {@link NClobImplementer}. In JDK 1.6
+ * environments, also castable to java.sql.NClob
+ */
+ public Clob createNClob(Reader reader, long length);
+}
15 years, 11 months
Hibernate SVN: r17770 - in core/trunk: jdbc3-testing and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-10-15 19:42:48 -0400 (Thu, 15 Oct 2009)
New Revision: 17770
Modified:
core/trunk/core/src/main/java/org/hibernate/engine/jdbc/NClobImplementer.java
core/trunk/jdbc3-testing/pom.xml
core/trunk/jdbc4-testing/pom.xml
core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4/JdbcSupportTest.java
Log:
HHH-2412 - Support for JDBC4
Modified: core/trunk/core/src/main/java/org/hibernate/engine/jdbc/NClobImplementer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/jdbc/NClobImplementer.java 2009-10-15 19:08:41 UTC (rev 17769)
+++ core/trunk/core/src/main/java/org/hibernate/engine/jdbc/NClobImplementer.java 2009-10-15 23:42:48 UTC (rev 17770)
@@ -30,5 +30,5 @@
*
* @author Steve Ebersole
*/
-public interface NClobImplementer {
+public interface NClobImplementer extends ClobImplementer {
}
Modified: core/trunk/jdbc3-testing/pom.xml
===================================================================
--- core/trunk/jdbc3-testing/pom.xml 2009-10-15 19:08:41 UTC (rev 17769)
+++ core/trunk/jdbc3-testing/pom.xml 2009-10-15 23:42:48 UTC (rev 17770)
@@ -43,18 +43,6 @@
<artifactId>hibernate-core</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>8.4-701.jdbc4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.10</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
Modified: core/trunk/jdbc4-testing/pom.xml
===================================================================
--- core/trunk/jdbc4-testing/pom.xml 2009-10-15 19:08:41 UTC (rev 17769)
+++ core/trunk/jdbc4-testing/pom.xml 2009-10-15 23:42:48 UTC (rev 17770)
@@ -70,24 +70,6 @@
<artifactId>hibernate-core</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>8.4-701.jdbc4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.10</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc6</artifactId>
- <version>11.1.0.7.0</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
Modified: core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4/JdbcSupportTest.java
===================================================================
--- core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4/JdbcSupportTest.java 2009-10-15 19:08:41 UTC (rev 17769)
+++ core/trunk/jdbc4-testing/src/test/java/org/hibernate/engine/jdbc/jdbc4/JdbcSupportTest.java 2009-10-15 23:42:48 UTC (rev 17770)
@@ -21,15 +21,20 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.hibernate.engine.jdbc.jdbc4;
import java.sql.SQLException;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.NClob;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
import junit.framework.TestCase;
@@ -50,227 +55,267 @@
* @author Steve Ebersole
*/
public class JdbcSupportTest extends TestCase {
- private interface Envionment {
- public String getDriver();
- public String getUrl();
- public String getUser();
- public String getPass();
+ public void testConnectedLobCreator() throws SQLException {
+ final Connection connection = createConnectionProxy(
+ new JdbcLobBuilder() {
+ public Blob createBlob() {
+ return new JdbcBlob();
+ }
- public void verifyCreator(LobCreator lobCreator);
- public void verifyBlob(Blob blob);
- public void verifyClob(Clob clob);
- public void verifyNClob(Clob nclob);
+ public Clob createClob() {
+ return new JdbcClob();
+ }
+
+ public NClob createNClob() {
+ return new JdbcNClob();
+ }
+ }
+ );
+ final LobCreationContext lobCreationContext = new LobCreationContext() {
+ public Object execute(Callback callback) {
+ try {
+ return callback.executeOnConnection( connection );
+ }
+ catch ( SQLException e ) {
+ throw new RuntimeException( "Unexpected SQLException", e );
+ }
+ }
+ };
+
+ LobCreator lobCreator = JdbcSupportLoader.loadJdbcSupport( connection ).getLobCreator( lobCreationContext );
+ assertTrue( lobCreator instanceof ContextualLobCreator );
+
+ Blob blob = lobCreator.createBlob( new byte[] {} );
+ assertTrue( blob instanceof JdbcBlob );
+ blob = lobCreator.wrap( blob );
+ assertTrue( blob instanceof WrappedBlob );
+
+ Clob clob = lobCreator.createClob( "Hi" );
+ assertTrue( clob instanceof JdbcClob );
+ clob = lobCreator.wrap( clob );
+ assertTrue( clob instanceof WrappedClob );
+
+ Clob nclob = lobCreator.createNClob( "Hi" );
+ assertTrue( nclob instanceof JdbcNClob );
+ nclob = lobCreator.wrap( nclob );
+ assertTrue( nclob instanceof WrappedClob );
+
+ blob.free();
+ clob.free();
+ nclob.free();
+ connection.close();
}
- private abstract class ContextualEnvironment implements Envionment {
- public void verifyCreator(LobCreator lobCreator) {
- assertTrue( lobCreator instanceof ContextualLobCreator );
- }
+ public void testConnectedLobCreatorWithUnSupportedCreations() throws SQLException {
+ final Connection connection = createConnectionProxy(
+ new JdbcLobBuilder() {
+ public Blob createBlob() {
+ throw new UnsupportedOperationException();
+ }
- public void verifyBlob(Blob blob) {
- assertFalse( blob instanceof BlobImplementer );
- }
+ public Clob createClob() {
+ throw new UnsupportedOperationException();
+ }
- public void verifyClob(Clob clob) {
- assertFalse( clob instanceof ClobImplementer );
- }
+ public NClob createNClob() {
+ throw new UnsupportedOperationException();
+ }
+ }
+ );
+ final LobCreationContext lobCreationContext = new LobCreationContext() {
+ public Object execute(Callback callback) {
+ try {
+ return callback.executeOnConnection( connection );
+ }
+ catch ( SQLException e ) {
+ throw new RuntimeException( "Unexpected SQLException", e );
+ }
+ }
+ };
- public void verifyNClob(Clob nclob) {
- assertFalse( nclob instanceof NClobImplementer );
- }
+ LobCreator lobCreator = JdbcSupportLoader.loadJdbcSupport( connection ).getLobCreator( lobCreationContext );
+ assertTrue( lobCreator instanceof NonContextualLobCreator );
+
+ Blob blob = lobCreator.createBlob( new byte[] {} );
+ assertTrue( blob instanceof BlobImplementer );
+ blob = lobCreator.wrap( blob );
+ assertTrue( blob instanceof WrappedBlob );
+
+ Clob clob = lobCreator.createClob( "Hi" );
+ assertTrue( clob instanceof ClobImplementer );
+ clob = lobCreator.wrap( clob );
+ assertTrue( clob instanceof WrappedClob );
+
+ Clob nclob = lobCreator.createNClob( "Hi" );
+ assertTrue( nclob instanceof ClobImplementer );
+ assertTrue( nclob instanceof NClobImplementer );
+ nclob = lobCreator.wrap( nclob );
+ assertTrue( nclob instanceof WrappedClob );
+
+ blob.free();
+ clob.free();
+ nclob.free();
+ connection.close();
}
- private abstract class NonContextualEnvironment implements Envionment {
- public void verifyCreator(LobCreator lobCreator) {
- assertTrue( lobCreator instanceof NonContextualLobCreator );
- }
+ public void testLegacyLobCreator() throws SQLException {
+ LobCreator lobCreator = JdbcSupportLoader.loadJdbcSupport( null ).getLobCreator();
- public void verifyBlob(Blob blob) {
- assertTrue( blob instanceof BlobImplementer );
- }
+ Blob blob = lobCreator.createBlob( new byte[] {} );
+ assertTrue( blob instanceof BlobImplementer );
+ blob = lobCreator.wrap( blob );
+ assertTrue( blob instanceof WrappedBlob );
- public void verifyClob(Clob clob) {
- assertTrue( clob instanceof ClobImplementer );
+ Clob clob = lobCreator.createClob( "Hi" );
+ assertTrue( clob instanceof ClobImplementer );
+ clob = lobCreator.wrap( clob );
+ assertTrue( clob instanceof WrappedClob );
+
+ Clob nclob = lobCreator.createNClob( "Hi" );
+ assertTrue( nclob instanceof NClobImplementer );
+ assertTrue( NClob.class.isInstance( nclob ) );
+ nclob = lobCreator.wrap( nclob );
+ assertTrue( nclob instanceof WrappedClob );
+
+ blob.free();
+ clob.free();
+ nclob.free();
+ }
+
+ private interface JdbcLobBuilder {
+ public Blob createBlob();
+ public Clob createClob();
+ public NClob createNClob();
+ }
+
+ private class ConnectionProxyHandler implements InvocationHandler {
+ private final JdbcLobBuilder lobBuilder;
+
+ private ConnectionProxyHandler(JdbcLobBuilder lobBuilder) {
+ this.lobBuilder = lobBuilder;
}
- public void verifyNClob(Clob nclob) {
- assertTrue( nclob instanceof NClobImplementer );
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ // the only methods we are interested in are the LOB creation methods...
+ if ( args == null || args.length == 0 ) {
+ final String methodName = method.getName();
+ if ( "createBlob".equals( methodName ) ) {
+ return lobBuilder.createBlob();
+ }
+ else if ( "createClob".equals( methodName ) ) {
+ return lobBuilder.createClob();
+ }
+ else if ( "createNClob".equals( methodName ) ) {
+ return lobBuilder.createNClob();
+ }
+ }
+ return null;
}
}
- private Envionment POSTGRESQL = new NonContextualEnvironment() {
- public String getDriver() {
- return "org.postgresql.Driver";
+ private static Class[] PROXY_TYPES = new Class[] { Connection.class };
+
+ private Connection createConnectionProxy(JdbcLobBuilder jdbcLobBuilder) {
+ ConnectionProxyHandler handler = new ConnectionProxyHandler( jdbcLobBuilder );
+ return ( Connection ) Proxy.newProxyInstance( getClass().getClassLoader(), PROXY_TYPES, handler );
+ }
+
+ private class JdbcBlob implements Blob {
+ public long length() throws SQLException {
+ return 0;
}
- public String getUrl() {
- return "jdbc:postgresql://vmg03.mw.lab.eng.bos.redhat.com:5432:platformae";
+ public byte[] getBytes(long pos, int length) throws SQLException {
+ return new byte[0];
}
- public String getUser() {
- return "sebersole";
+ public InputStream getBinaryStream() throws SQLException {
+ return null;
}
- public String getPass() {
- return "sebersole";
+ public long position(byte[] pattern, long start) throws SQLException {
+ return 0;
}
- };
- private Envionment MYSQL = new ContextualEnvironment() {
- public String getDriver() {
- return "com.mysql.jdbc.Driver";
+ public long position(Blob pattern, long start) throws SQLException {
+ return 0;
}
- public String getUrl() {
- return "jdbc:mysql://vmg02.mw.lab.eng.bos.redhat.com/sebersole";
+ public int setBytes(long pos, byte[] bytes) throws SQLException {
+ return 0;
}
- public String getUser() {
- return "sebersole";
+ public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException {
+ return 0;
}
- public String getPass() {
- return "sebersole";
+ public OutputStream setBinaryStream(long pos) throws SQLException {
+ return null;
}
- };
- private Envionment ORACLE9i = new ContextualEnvironment() {
- public String getDriver() {
- return "oracle.jdbc.driver.OracleDriver";
+ public void truncate(long len) throws SQLException {
}
- public String getUrl() {
- return "jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa";
+ public void free() throws SQLException {
}
- public String getUser() {
- return "sebersole";
+ public InputStream getBinaryStream(long pos, long length) throws SQLException {
+ return null;
}
+ }
- public String getPass() {
- return "sebersole";
+ private class JdbcClob implements Clob {
+ public long length() throws SQLException {
+ return 0;
}
- };
- private Envionment ORACLE10g = new ContextualEnvironment() {
- public String getDriver() {
- return "oracle.jdbc.driver.OracleDriver";
+ public String getSubString(long pos, int length) throws SQLException {
+ return null;
}
- public String getUrl() {
- return "jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.com:1521:qaora10";
+ public Reader getCharacterStream() throws SQLException {
+ return null;
}
- public String getUser() {
- return "sebersole";
+ public InputStream getAsciiStream() throws SQLException {
+ return null;
}
- public String getPass() {
- return "sebersole";
+ public long position(String searchstr, long start) throws SQLException {
+ return 0;
}
- };
- private Envionment ORACLE11g = new ContextualEnvironment() {
- public String getDriver() {
- return "oracle.jdbc.driver.OracleDriver";
+ public long position(Clob searchstr, long start) throws SQLException {
+ return 0;
}
- public String getUrl() {
- return "jdbc:oracle:thin:@dev04.qa.atl2.redhat.com:1521:qaora11";
+ public int setString(long pos, String str) throws SQLException {
+ return 0;
}
- public String getUser() {
- return "sebersole";
+ public int setString(long pos, String str, int offset, int len) throws SQLException {
+ return 0;
}
- public String getPass() {
- return "sebersole";
+ public OutputStream setAsciiStream(long pos) throws SQLException {
+ return null;
}
- };
- private Envionment ORACLE_RAC = new ContextualEnvironment() {
- public String getDriver() {
- return "oracle.jdbc.driver.OracleDriver";
+ public Writer setCharacterStream(long pos) throws SQLException {
+ return null;
}
- public String getUrl() {
- return "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=vmg24-vip.mw.lab.eng.bos.redhat.com)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vmg25-vip.mw.lab.eng.bos.redhat.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=qarac.jboss))";
+ public void truncate(long len) throws SQLException {
}
- public String getUser() {
- return "sebersole";
+ public void free() throws SQLException {
}
- public String getPass() {
- return "sebersole";
+ public Reader getCharacterStream(long pos, long length) throws SQLException {
+ return null;
}
- };
-
- private Envionment envionment = ORACLE11g;
-
- protected void setUp() throws Exception {
- Class.forName( envionment.getDriver() );
}
- public void testConnectedLobCreator() throws SQLException {
- final Connection connection = DriverManager.getConnection( envionment.getUrl(), envionment.getUser(), envionment.getPass() );
- final LobCreationContext lobCreationContext = new LobCreationContext() {
- public Object execute(Callback callback) {
- try {
- return callback.executeOnConnection( connection );
- }
- catch ( SQLException e ) {
- throw new RuntimeException( "Unexpected sql exception", e );
- }
- }
- };
-
- LobCreator lobCreator = JdbcSupportLoader.loadJdbcSupport( connection ).getLobCreator( lobCreationContext );
- envionment.verifyCreator( lobCreator );
-
- Blob blob = lobCreator.createBlob( new byte[] {} );
- envionment.verifyBlob( blob );
- blob = lobCreator.wrap( blob );
- assertTrue( blob instanceof WrappedBlob );
-
- Clob clob = lobCreator.createClob( "Hi" );
- envionment.verifyClob( clob );
- clob = lobCreator.wrap( clob );
- assertTrue( clob instanceof WrappedClob );
-
- Clob nclob = lobCreator.createNClob( "Hi" );
- envionment.verifyNClob( nclob );
- assertTrue( NClob.class.isInstance( nclob ) );
- nclob = lobCreator.wrap( nclob );
- assertTrue( nclob instanceof WrappedClob );
-
- blob.free();
- clob.free();
- nclob.free();
- connection.close();
+ private class JdbcNClob extends JdbcClob implements NClob {
}
-
- public void testLegacyLobCreator() throws SQLException {
- LobCreator lobCreator = JdbcSupportLoader.loadJdbcSupport( null ).getLobCreator();
-
- Blob blob = lobCreator.createBlob( new byte[] {} );
- assertTrue( blob instanceof BlobImplementer );
- blob = lobCreator.wrap( blob );
- assertTrue( blob instanceof WrappedBlob );
-
- Clob clob = lobCreator.createClob( "Hi" );
- assertTrue( clob instanceof ClobImplementer );
- clob = lobCreator.wrap( clob );
- assertTrue( clob instanceof WrappedClob );
-
- Clob nclob = lobCreator.createNClob( "Hi" );
- assertTrue( nclob instanceof NClobImplementer );
- assertTrue( NClob.class.isInstance( nclob ) );
- nclob = lobCreator.wrap( nclob );
- assertTrue( nclob instanceof WrappedClob );
-
- blob.free();
- clob.free();
- nclob.free();
- }
}
15 years, 11 months
Hibernate SVN: r17769 - core/trunk/cache-infinispan.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-10-15 15:08:41 -0400 (Thu, 15 Oct 2009)
New Revision: 17769
Modified:
core/trunk/cache-infinispan/
Log:
expanded svn:ignore list
Property changes on: core/trunk/cache-infinispan
___________________________________________________________________
Name: svn:ignore
- target
.project
.classpath
.settings
+ target
local
*.ipr
*.iws
*.iml
.classpath
.project
.settings
.nbattrs
*.log
*.properties
.clover
15 years, 11 months