HHH-5163 : added logging and test cases for ClassCastException when caching transformed query results
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20074 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
7e5bae6660
commit
7689d5e33c
|
@ -173,6 +173,10 @@ public class QueryKey implements Serializable {
|
|||
this.hashCode = generateHashCode();
|
||||
}
|
||||
|
||||
public ResultTransformer getResultTransformer() {
|
||||
return customTransformer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialization hook used to re-init the cached hashcode which is needed for proper clustering support.
|
||||
*
|
||||
|
|
|
@ -2275,6 +2275,13 @@ public abstract class Loader {
|
|||
session
|
||||
);
|
||||
|
||||
if ( querySpaces == null || querySpaces.size() == 0 ) {
|
||||
log.trace( "unexpected querySpaces is "+( querySpaces == null ? "null" : "empty" ) );
|
||||
}
|
||||
else {
|
||||
log.trace( "querySpaces is "+querySpaces.toString() );
|
||||
}
|
||||
|
||||
List result = getResultFromQueryCache(
|
||||
session,
|
||||
queryParameters,
|
||||
|
@ -2327,6 +2334,11 @@ public abstract class Loader {
|
|||
}
|
||||
try {
|
||||
result = queryCache.get( key, resultTypes, isImmutableNaturalKeyLookup, querySpaces, session );
|
||||
logCachedResultDetails(
|
||||
key.getResultTransformer(),
|
||||
resultTypes,
|
||||
result
|
||||
);
|
||||
}
|
||||
finally {
|
||||
persistenceContext.setDefaultReadOnly( defaultReadOnlyOrig );
|
||||
|
@ -2355,6 +2367,13 @@ public abstract class Loader {
|
|||
final QueryKey key,
|
||||
final List result) {
|
||||
if ( session.getCacheMode().isPutEnabled() ) {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
logCachedResultDetails(
|
||||
key.getResultTransformer(),
|
||||
resultTypes,
|
||||
result
|
||||
);
|
||||
}
|
||||
boolean put = queryCache.put( key, resultTypes, result, queryParameters.isNaturalKeyLookup(), session );
|
||||
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
|
||||
factory.getStatisticsImplementor()
|
||||
|
@ -2363,6 +2382,86 @@ public abstract class Loader {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void logCachedResultDetails(ResultTransformer resultTransformer, Type[] returnTypes, List result) {
|
||||
if ( ! log.isTraceEnabled() ) {
|
||||
return;
|
||||
}
|
||||
if ( returnTypes == null || returnTypes.length == 0 ) {
|
||||
log.trace( "unexpected returnTypes is "+( returnTypes == null ? "null" : "empty" )+
|
||||
"! transformer="+( resultTransformer == null ? "null" : resultTransformer.getClass().getName() )+
|
||||
" result"+( result == null ? " is null": ".size()=" + result.size() ) );
|
||||
}
|
||||
else {
|
||||
StringBuffer returnTypeNames = new StringBuffer();
|
||||
StringBuffer returnClassNames = new StringBuffer();
|
||||
for ( int i=0; i<returnTypes.length; i++ ) {
|
||||
returnTypeNames.append( returnTypes[ i ].getName() ).append(' ');
|
||||
returnClassNames.append( returnTypes[ i ].getReturnedClass() ).append(' ');
|
||||
}
|
||||
log.trace( "transformer="+( resultTransformer == null ? "null" : resultTransformer.getClass().getName() )+
|
||||
" returnTypes=[ "+returnTypeNames+"]"+" returnClasses=[ "+returnClassNames+"]" );
|
||||
}
|
||||
if ( result != null && result.size() != 0 ) {
|
||||
for ( Iterator it = result.iterator(); it.hasNext(); ) {
|
||||
Object value = it.next();
|
||||
if ( value == null ) {
|
||||
log.trace( "transformer="+( resultTransformer == null ? "null" : resultTransformer.getClass().getName() )+
|
||||
" value is null; returnTypes is "+( returnTypes == null ? "null" : "Type["+returnTypes.length+"]" ) );
|
||||
if ( returnTypes != null && returnTypes.length > 1 ) {
|
||||
log.trace( "unexpected result value! "+
|
||||
"transformer="+( resultTransformer == null ? "null" : resultTransformer.getClass().getName() )+
|
||||
"value is null; should be Object["+returnTypes.length+"]!" );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( returnTypes == null || returnTypes.length == 0 ) {
|
||||
log.trace( "unexpected result value! "+
|
||||
"transformer="+( resultTransformer == null ? "null" : resultTransformer.getClass().getName() )+
|
||||
"value is non-null; returnTypes is "+( returnTypes == null ? "null" : "empty" ) );
|
||||
}
|
||||
else if ( Object[].class.isInstance( value ) ) {
|
||||
Object[] tuple = ( Object[] ) value;
|
||||
log.trace( "transformer="+( resultTransformer == null ? "null" : resultTransformer.getClass().getName() )+
|
||||
" value is Object["+tuple.length+
|
||||
"]; returnTypes is Type["+returnTypes.length+"]" );
|
||||
if ( tuple.length != returnTypes.length ) {
|
||||
log.trace( "unexpected tuple length! transformer="+
|
||||
( resultTransformer == null ? "null" : resultTransformer.getClass().getName() )+
|
||||
" expected="+returnTypes.length+
|
||||
" got="+tuple.length );
|
||||
}
|
||||
else {
|
||||
for ( int j = 0; j < tuple.length; j++ ) {
|
||||
if ( tuple[ j ] != null && ! returnTypes[ j ].getReturnedClass().isInstance( tuple[ j ] ) ) {
|
||||
log.trace( "unexpected tuple value type! transformer="+
|
||||
( resultTransformer == null ? "null" : resultTransformer.getClass().getName() )+
|
||||
" expected="+returnTypes[ j ].getReturnedClass().getName()+
|
||||
" got="+tuple[ j ].getClass().getName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( returnTypes.length != 1 ) {
|
||||
log.trace( "unexpected number of result columns! should be Object["+returnTypes.length+"]! transformer="+
|
||||
( resultTransformer == null ? "null" : resultTransformer.getClass().getName() )+
|
||||
" value type="+value.getClass().getName()+
|
||||
" returnTypes is Type["+returnTypes.length+"]" );
|
||||
}
|
||||
else if ( ! returnTypes[ 0 ].getReturnedClass().isInstance( value ) ) {
|
||||
log.trace( "unexpected value type! transformer="+
|
||||
( resultTransformer == null ? "null" : resultTransformer.getClass().getName() )+
|
||||
" expected="+returnTypes[ 0 ].getReturnedClass().getName()+
|
||||
" got="+ value.getClass().getName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Actually execute a query, ignoring the query cache
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,134 @@
|
|||
// $Id: Address.java 7996 2005-08-22 14:49:57Z steveebersole $
|
||||
package org.hibernate.test.querycache;
|
||||
|
||||
/**
|
||||
* Implementation of Address.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class Address {
|
||||
private long id;
|
||||
private String addressType;
|
||||
private String street;
|
||||
private String city;
|
||||
private String stateProvince;
|
||||
private String postalCode;
|
||||
private String country;
|
||||
private Student student;
|
||||
|
||||
public Address() {}
|
||||
|
||||
public Address(Student student, String type, String street, String city, String stateProvince, String postalCode, String country) {
|
||||
this.student = student;
|
||||
this.addressType = type;
|
||||
this.street = street;
|
||||
this.city = city;
|
||||
this.stateProvince = stateProvince;
|
||||
this.postalCode = postalCode;
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Student getStudent() {
|
||||
return student;
|
||||
}
|
||||
|
||||
public void setStudent(Student student) {
|
||||
this.student = student;
|
||||
}
|
||||
|
||||
public String getAddressType() {
|
||||
return addressType;
|
||||
}
|
||||
|
||||
public void setAddressType(String addressType) {
|
||||
this.addressType = addressType;
|
||||
}
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getPostalCode() {
|
||||
return postalCode;
|
||||
}
|
||||
|
||||
public void setPostalCode(String postalCode) {
|
||||
this.postalCode = postalCode;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getStateProvince() {
|
||||
return stateProvince;
|
||||
}
|
||||
|
||||
public void setStateProvince(String stateProvince) {
|
||||
this.stateProvince = stateProvince;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Address address = ( Address ) o;
|
||||
|
||||
if ( city != null ? !city.equals( address.city ) : address.city != null ) {
|
||||
return false;
|
||||
}
|
||||
if ( country != null ? !country.equals( address.country ) : address.country != null ) {
|
||||
return false;
|
||||
}
|
||||
if ( postalCode != null ? !postalCode.equals( address.postalCode ) : address.postalCode != null ) {
|
||||
return false;
|
||||
}
|
||||
if ( stateProvince != null ? !stateProvince.equals( address.stateProvince ) : address.stateProvince != null ) {
|
||||
return false;
|
||||
}
|
||||
if ( street != null ? !street.equals( address.street ) : address.street != null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = street != null ? street.hashCode() : 0;
|
||||
result = 31 * result + ( city != null ? city.hashCode() : 0 );
|
||||
result = 31 * result + ( stateProvince != null ? stateProvince.hashCode() : 0 );
|
||||
result = 31 * result + ( postalCode != null ? postalCode.hashCode() : 0 );
|
||||
result = 31 * result + ( country != null ? country.hashCode() : 0 );
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
//$Id: Course.java 5686 2005-02-12 07:27:32Z steveebersole $
|
||||
package org.hibernate.test.querycache;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
public class Course implements Serializable {
|
||||
private String courseCode;
|
||||
private String description;
|
||||
private Set courseMeetings = new HashSet();
|
||||
|
||||
public String getCourseCode() {
|
||||
return courseCode;
|
||||
}
|
||||
public void setCourseCode(String courseCode) {
|
||||
this.courseCode = courseCode;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public Set getCourseMeetings() {
|
||||
return courseMeetings;
|
||||
}
|
||||
public void setCourseMeetings(Set courseMeetings) {
|
||||
this.courseMeetings = courseMeetings;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || ! ( o instanceof Course ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Course course = ( Course ) o;
|
||||
|
||||
if ( courseCode != null ? !courseCode.equals( course.getCourseCode() ) : course.getCourseCode() != null ) {
|
||||
return false;
|
||||
}
|
||||
if ( description != null ? !description.equals( course.getDescription() ) : course.getDescription() != null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = courseCode != null ? courseCode.hashCode() : 0;
|
||||
result = 31 * result + ( description != null ? description.hashCode() : 0 );
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.hibernate.test.querycache;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class CourseMeeting {
|
||||
private CourseMeetingId id;
|
||||
private Course course;
|
||||
|
||||
public CourseMeeting() {}
|
||||
|
||||
public CourseMeeting(Course course, String day, int period, String location) {
|
||||
this.id = new CourseMeetingId( course, day, period, location );
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public CourseMeetingId getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(CourseMeetingId id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Course getCourse() {
|
||||
return course;
|
||||
}
|
||||
public void setCourse(Course course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CourseMeeting that = ( CourseMeeting ) o;
|
||||
|
||||
if ( course != null ? !course.equals( that.course ) : that.course != null ) {
|
||||
return false;
|
||||
}
|
||||
if ( id != null ? !id.equals( that.id ) : that.id != null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + ( course != null ? course.hashCode() : 0 );
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package org.hibernate.test.querycache;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class CourseMeetingId implements Serializable {
|
||||
private String courseCode;
|
||||
private String day;
|
||||
private int period;
|
||||
private String location;
|
||||
|
||||
public CourseMeetingId() {}
|
||||
|
||||
public CourseMeetingId(Course course, String day, int period, String location) {
|
||||
this.courseCode = course.getCourseCode();
|
||||
this.day = day;
|
||||
this.period = period;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getCourseCode() {
|
||||
return courseCode;
|
||||
}
|
||||
public void setCourseCode(String courseCode) {
|
||||
this.courseCode = courseCode;
|
||||
}
|
||||
public String getDay() {
|
||||
return day;
|
||||
}
|
||||
public void setDay(String day) {
|
||||
this.day = day;
|
||||
}
|
||||
public int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
public void setPeriod(int period) {
|
||||
this.period = period;
|
||||
}
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CourseMeetingId that = ( CourseMeetingId ) o;
|
||||
|
||||
if ( period != that.period ) {
|
||||
return false;
|
||||
}
|
||||
if ( courseCode != null ? !courseCode.equals( that.courseCode ) : that.courseCode != null ) {
|
||||
return false;
|
||||
}
|
||||
if ( day != null ? !day.equals( that.day ) : that.day != null ) {
|
||||
return false;
|
||||
}
|
||||
if ( location != null ? !location.equals( that.location ) : that.location != null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = courseCode != null ? courseCode.hashCode() : 0;
|
||||
result = 31 * result + ( day != null ? day.hashCode() : 0 );
|
||||
result = 31 * result + period;
|
||||
result = 31 * result + ( location != null ? location.hashCode() : 0 );
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* 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.test.querycache;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class CriteriaQueryCacheIgnoreResultTransformerTest extends AbstractQueryCacheResultTransformerTest {
|
||||
|
||||
public CriteriaQueryCacheIgnoreResultTransformerTest(String str) {
|
||||
super( str );
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( CriteriaQueryCacheIgnoreResultTransformerTest.class );
|
||||
}
|
||||
|
||||
protected CacheMode getQueryCacheMode() {
|
||||
return CacheMode.IGNORE;
|
||||
}
|
||||
|
||||
protected void runTest(HqlExecutor hqlExecutor, CriteriaExecutor criteriaExecutor, ResultChecker checker, boolean isSingleResult)
|
||||
throws Exception {
|
||||
createData();
|
||||
if ( criteriaExecutor != null ) {
|
||||
runTest( criteriaExecutor, checker, isSingleResult );
|
||||
}
|
||||
deleteData();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* 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.test.querycache;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class CriteriaQueryCacheNormalResultTransformerTest extends CriteriaQueryCachePutResultTransformerTest {
|
||||
|
||||
public CriteriaQueryCacheNormalResultTransformerTest(String str) {
|
||||
super( str );
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( CriteriaQueryCacheNormalResultTransformerTest.class );
|
||||
}
|
||||
|
||||
protected CacheMode getQueryCacheMode() {
|
||||
return CacheMode.NORMAL;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* 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.test.querycache;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class CriteriaQueryCachePutResultTransformerTest extends CriteriaQueryCacheIgnoreResultTransformerTest {
|
||||
|
||||
public CriteriaQueryCachePutResultTransformerTest(String str) {
|
||||
super( str );
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( CriteriaQueryCachePutResultTransformerTest.class );
|
||||
}
|
||||
|
||||
protected CacheMode getQueryCacheMode() {
|
||||
return CacheMode.PUT;
|
||||
}
|
||||
|
||||
protected boolean areDynamicNonLazyAssociationsChecked() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapNoProjectionList() {
|
||||
reportSkip( "Transformers.ALIAS_TO_ENTITY_MAP with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.ALIAS_TO_ENTITY_MAP with Criteria" );
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapNoProjectionListFailureExpected() throws Exception {
|
||||
super.testAliasToEntityMapNoProjectionList();
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapNoProjectionMultiAndNullList() {
|
||||
reportSkip( "Transformers.ALIAS_TO_ENTITY_MAP with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.ALIAS_TO_ENTITY_MAP with Criteria" );
|
||||
}
|
||||
public void testAliasToEntityMapNoProjectionMultiAndNullListFailureExpected() throws Exception {
|
||||
super.testAliasToEntityMapNoProjectionMultiAndNullList();
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapOneProjectionList() {
|
||||
reportSkip( "Transformers.ALIAS_TO_ENTITY_MAP with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.ALIAS_TO_ENTITY_MAP with Criteria" );
|
||||
}
|
||||
public void testAliasToEntityMapOneProjectionListFailureExpected() throws Exception {
|
||||
super.testAliasToEntityMapOneProjectionList();
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapMultiProjectionList() {
|
||||
reportSkip( "Transformers.ALIAS_TO_ENTITY_MAP with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.ALIAS_TO_ENTITY_MAP with Criteria" );
|
||||
}
|
||||
public void testAliasToEntityMapMultiProjectionListFailureExpected() throws Exception {
|
||||
super.testAliasToEntityMapMultiProjectionList();
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapMultiProjectionWithNullAliasList() {
|
||||
reportSkip( "Transformers.ALIAS_TO_ENTITY_MAP with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.ALIAS_TO_ENTITY_MAP with Criteria" );
|
||||
}
|
||||
public void testAliasToEntityMapMultiProjectionWithNullAliasListFailureExpected() throws Exception {
|
||||
super.testAliasToEntityMapMultiProjectionWithNullAliasList();
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapMultiAggregatedPropProjectionSingleResult() {
|
||||
reportSkip( "Transformers.ALIAS_TO_ENTITY_MAP with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.ALIAS_TO_ENTITY_MAP with Criteria" );
|
||||
}
|
||||
public void testAliasToEntityMapMultiAggregatedPropProjectionSingleResultFailureExpected() throws Exception {
|
||||
super.testAliasToEntityMapMultiAggregatedPropProjectionSingleResult();
|
||||
}
|
||||
|
||||
public void testAliasToBeanDtoOneArgList() {
|
||||
reportSkip( "Transformers.aliasToBean with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.aliasToBean with Criteria" );
|
||||
}
|
||||
public void testAliasToBeanDtoOneArgListFailureExpected() throws Exception {
|
||||
super.testAliasToBeanDtoOneArgList();
|
||||
}
|
||||
|
||||
public void testAliasToBeanDtoMultiArgList() {
|
||||
reportSkip( "Transformers.aliasToBean with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.aliasToBean with Criteria" );
|
||||
}
|
||||
public void testAliasToBeanDtoMultiArgListFailureExpected() throws Exception {
|
||||
super.testAliasToBeanDtoMultiArgList();
|
||||
}
|
||||
|
||||
public void testAliasToBeanDtoLiteralArgList() {
|
||||
reportSkip( "Transformers.aliasToBean with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.aliasToBean with Criteria" );
|
||||
}
|
||||
public void testAliasToBeanDtoLiteralArgListFailureExpected() throws Exception {
|
||||
super.testAliasToBeanDtoLiteralArgList();
|
||||
}
|
||||
|
||||
public void testAliasToBeanDtoWithNullAliasList() {
|
||||
reportSkip( "Transformers.aliasToBean with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.aliasToBean with Criteria" );
|
||||
}
|
||||
public void testAliasToBeanDtoWithNullAliasListFailureExpected() throws Exception {
|
||||
super.testAliasToBeanDtoWithNullAliasList();
|
||||
}
|
||||
|
||||
public void testOneSelectNewList() {
|
||||
reportSkip( "Transformers.aliasToBean with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.aliasToBean with Criteria" );
|
||||
}
|
||||
public void testOneSelectNewListFailureExpected() throws Exception {
|
||||
super.testOneSelectNewList();
|
||||
}
|
||||
|
||||
public void testMultiSelectNewList() {
|
||||
reportSkip( "Transformers.aliasToBean with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.aliasToBean with Criteria" );
|
||||
}
|
||||
public void testMultiSelectNewListFailureExpected() throws Exception {
|
||||
super.testMultiSelectNewList();
|
||||
}
|
||||
|
||||
public void testMultiSelectNewWithLiteralList() {
|
||||
reportSkip( "Transformers.aliasToBean with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.aliasToBean with Criteria" );
|
||||
}
|
||||
public void testMultiSelectNewWithLiteralListFailureExpected() throws Exception {
|
||||
super.testMultiSelectNewWithLiteralList();
|
||||
}
|
||||
|
||||
public void testMultiSelectNewListList() {
|
||||
reportSkip( "Transformers.aliasToBean with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.aliasToBean with Criteria" );
|
||||
}
|
||||
public void testMultiSelectNewListListFailureExpected() throws Exception {
|
||||
super.testMultiSelectNewListList();
|
||||
}
|
||||
|
||||
public void testMultiSelectNewMapList() {
|
||||
reportSkip( "Transformers.aliasToBean with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.aliasToBean with Criteria" );
|
||||
}
|
||||
public void testMultiSelectNewMapListFailureExpected() throws Exception {
|
||||
super.testMultiSelectNewMapList();
|
||||
}
|
||||
|
||||
public void testSelectNewEntityConstructorList() {
|
||||
reportSkip( "Transformers.aliasToBean with Criteria fails when try put in cache",
|
||||
"Cache results using Transformers.aliasToBean with Criteria" );
|
||||
}
|
||||
public void testSelectNewEntityConstructorListFailureExpected() throws Exception {
|
||||
super.testMultiSelectNewMapList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.querycache">
|
||||
|
||||
<class name="Course">
|
||||
<id name="courseCode">
|
||||
<generator class="assigned"/>
|
||||
</id>
|
||||
<property name="description"/>
|
||||
<set name="courseMeetings" inverse="true" cascade="all-delete-orphan" lazy="false">
|
||||
<key column="courseCode"/>
|
||||
<one-to-many class="CourseMeeting"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="CourseMeeting">
|
||||
<composite-id name="id" class="CourseMeetingId">
|
||||
<key-property name="courseCode"/>
|
||||
<key-property name="day"/>
|
||||
<key-property name="period"/>
|
||||
<key-property name="location"/>
|
||||
</composite-id>
|
||||
<many-to-one name="course" insert="false" update="false" lazy="false">
|
||||
<column name="courseCode"/>
|
||||
</many-to-one>
|
||||
</class>
|
||||
|
||||
<class name="Student">
|
||||
<id name="studentNumber">
|
||||
<column name="studentId"/>
|
||||
<generator class="assigned"/>
|
||||
</id>
|
||||
<component name="name">
|
||||
<property name="first" column="name_first" not-null="true"/>
|
||||
<property name="middle" column="name_middle" not-null="false"/>
|
||||
<property name="last" column="name_last" not-null="true"/>
|
||||
</component>
|
||||
<set name="enrolments" inverse="true" cascade="delete">
|
||||
<key column="studentId"/>
|
||||
<one-to-many class="Enrolment"/>
|
||||
</set>
|
||||
<map name="addresses" table="addresses" cascade="all,delete" lazy="true">
|
||||
<key column="studentNumber"/>
|
||||
<map-key column="addressType" type="string"/>
|
||||
<one-to-many class="Address"/>
|
||||
</map>
|
||||
<many-to-one name="preferredCourse" column="preferredCourseCode" lazy="proxy"/>
|
||||
<list name="secretCodes" lazy="false">
|
||||
<key>
|
||||
<column name="studentNumber"/>
|
||||
</key>
|
||||
<index column="i"/>
|
||||
<element column="secretCode" type="int"/>
|
||||
</list>
|
||||
</class>
|
||||
|
||||
<class name="Address">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="addressType"/>
|
||||
<property name="street"/>
|
||||
<property name="city"/>
|
||||
<property name="stateProvince"/>
|
||||
<property name="postalCode"/>
|
||||
<property name="country"/>
|
||||
<many-to-one name="student" class="Student" column="studentNumber" not-null="false"/>
|
||||
</class>
|
||||
|
||||
<class name="Enrolment">
|
||||
<composite-id>
|
||||
<key-property name="studentNumber">
|
||||
<column name="studentId"/>
|
||||
</key-property>
|
||||
<key-property name="courseCode"/>
|
||||
</composite-id>
|
||||
<many-to-one name="student" insert="false" update="false" lazy="proxy">
|
||||
<column name="studentId"/>
|
||||
</many-to-one>
|
||||
<many-to-one name="course" insert="false" update="false" lazy="false">
|
||||
<column name="courseCode"/>
|
||||
</many-to-one>
|
||||
<property name="semester" type="short" not-null="true"/>
|
||||
<property name="year" column="`year`" type="short" not-null="true"/>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,87 @@
|
|||
//$Id: Enrolment.java 6970 2005-05-31 20:24:41Z oneovthafew $
|
||||
package org.hibernate.test.querycache;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
public class Enrolment implements Serializable {
|
||||
private Student student;
|
||||
private Course course;
|
||||
private long studentNumber;
|
||||
private String courseCode;
|
||||
private short year;
|
||||
private short semester;
|
||||
|
||||
public String getCourseCode() {
|
||||
return courseCode;
|
||||
}
|
||||
public void setCourseCode(String courseId) {
|
||||
this.courseCode = courseId;
|
||||
}
|
||||
public long getStudentNumber() {
|
||||
return studentNumber;
|
||||
}
|
||||
public void setStudentNumber(long studentId) {
|
||||
this.studentNumber = studentId;
|
||||
}
|
||||
public Course getCourse() {
|
||||
return course;
|
||||
}
|
||||
public void setCourse(Course course) {
|
||||
this.course = course;
|
||||
}
|
||||
public Student getStudent() {
|
||||
return student;
|
||||
}
|
||||
public void setStudent(Student student) {
|
||||
this.student = student;
|
||||
}
|
||||
public short getSemester() {
|
||||
return semester;
|
||||
}
|
||||
public void setSemester(short semester) {
|
||||
this.semester = semester;
|
||||
}
|
||||
public short getYear() {
|
||||
return year;
|
||||
}
|
||||
public void setYear(short year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Enrolment enrolment = ( Enrolment ) o;
|
||||
|
||||
if ( semester != enrolment.semester ) {
|
||||
return false;
|
||||
}
|
||||
if ( studentNumber != enrolment.studentNumber ) {
|
||||
return false;
|
||||
}
|
||||
if ( year != enrolment.year ) {
|
||||
return false;
|
||||
}
|
||||
if ( courseCode != null ? !courseCode.equals( enrolment.courseCode ) : enrolment.courseCode != null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = ( int ) ( studentNumber ^ ( studentNumber >>> 32 ) );
|
||||
result = 31 * result + ( courseCode != null ? courseCode.hashCode() : 0 );
|
||||
result = 31 * result + ( int ) year;
|
||||
result = 31 * result + ( int ) semester;
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* 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.test.querycache;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class HqlQueryCacheIgnoreResultTransformerTest extends AbstractQueryCacheResultTransformerTest {
|
||||
|
||||
public HqlQueryCacheIgnoreResultTransformerTest(String str) {
|
||||
super( str );
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( HqlQueryCacheIgnoreResultTransformerTest.class );
|
||||
}
|
||||
|
||||
protected CacheMode getQueryCacheMode() {
|
||||
return CacheMode.IGNORE;
|
||||
}
|
||||
|
||||
protected void runTest(HqlExecutor hqlExecutor, CriteriaExecutor criteriaExecutor, ResultChecker checker, boolean isSingleResult)
|
||||
throws Exception {
|
||||
createData();
|
||||
if ( hqlExecutor != null ) {
|
||||
runTest( hqlExecutor, checker, isSingleResult );
|
||||
}
|
||||
deleteData();
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapNoProjectionList() throws Exception {
|
||||
reportSkip( "known to fail using HQL", "HQL query using Transformers.ALIAS_TO_ENTITY_MAP with no projection" );
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapNoProjectionListFailureExpected() throws Exception {
|
||||
super.testAliasToEntityMapNoProjectionList();
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapNoProjectionMultiAndNullList() throws Exception {
|
||||
reportSkip( "known to fail using HQL", "HQL query using Transformers.ALIAS_TO_ENTITY_MAP with no projection" );
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapNoProjectionMultiAndNullListFailureExpected() throws Exception {
|
||||
super.testAliasToEntityMapNoProjectionMultiAndNullList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* 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.test.querycache;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class HqlQueryCacheNormalResultTransformerTest extends HqlQueryCachePutResultTransformerTest {
|
||||
|
||||
public HqlQueryCacheNormalResultTransformerTest(String str) {
|
||||
super( str );
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( HqlQueryCacheNormalResultTransformerTest.class );
|
||||
}
|
||||
|
||||
protected CacheMode getQueryCacheMode() {
|
||||
return CacheMode.NORMAL;
|
||||
}
|
||||
|
||||
public void testAliasToBeanDtoMultiArgList() {
|
||||
reportSkip( "Results from queries using Transformers.aliasToBean cannot be found in the cache due to bug in hashCode",
|
||||
"Query using Transformers.aliasToBean with cache"
|
||||
);
|
||||
}
|
||||
public void testAliasToBeanDtoMultiArgListFailureExpected() throws Exception {
|
||||
super.testAliasToBeanDtoMultiArgList();
|
||||
}
|
||||
|
||||
public void testAliasToBeanDtoLiteralArgList() {
|
||||
reportSkip( "Results from queries using Transformers.aliasToBean cannot be found in the cache due to bug in hashCode",
|
||||
"Query using Transformers.aliasToBean with cache" );
|
||||
}
|
||||
public void testAliasToBeanDtoLiteralArgListFailureExpected() throws Exception {
|
||||
super.testAliasToBeanDtoLiteralArgList();
|
||||
}
|
||||
|
||||
public void testAliasToBeanDtoWithNullAliasList() {
|
||||
reportSkip( "Results from queries using Transformers.aliasToBean cannot be found in the cache due to bug in hashCode",
|
||||
"Query using Transformers.aliasToBean with cache" );
|
||||
}
|
||||
public void testAliasToBeanDtoWithNullAliasListFailureExpected() throws Exception {
|
||||
super.testAliasToBeanDtoWithNullAliasList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* 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.test.querycache;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class HqlQueryCachePutResultTransformerTest extends HqlQueryCacheIgnoreResultTransformerTest {
|
||||
|
||||
public HqlQueryCachePutResultTransformerTest(String str) {
|
||||
super( str );
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( HqlQueryCachePutResultTransformerTest.class );
|
||||
}
|
||||
|
||||
|
||||
protected CacheMode getQueryCacheMode() {
|
||||
return CacheMode.PUT;
|
||||
}
|
||||
|
||||
protected boolean areDynamicNonLazyAssociationsChecked() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void testAliasToEntityMapOneProjectionList() {
|
||||
reportSkip( "HQL queries using a ResultTransformer are known to fail when caching a row with a single value",
|
||||
"HQL queries using a ResultTransformer has row with a single value");
|
||||
}
|
||||
public void testAliasToEntityMapOneProjectionListFailureExpected() throws Exception {
|
||||
super.testAliasToEntityMapOneProjectionList();
|
||||
}
|
||||
|
||||
public void testAliasToBeanDtoOneArgList() {
|
||||
reportSkip( "HQL queries using a ResultTransformer are known to fail when caching a row with a single value",
|
||||
"HQL queries using a ResultTransformer has row with a single value");
|
||||
}
|
||||
|
||||
public void testAliasToBeanDtoOneArgListFailureExpected() throws Exception {
|
||||
super.testAliasToBeanDtoOneArgList();
|
||||
}
|
||||
|
||||
public void testOneSelectNewList() {
|
||||
reportSkip( "HQL queries using a ResultTransformer are known to fail when caching a row with a single value",
|
||||
"HQL queries using a ResultTransformer has row with a single value");
|
||||
}
|
||||
public void testOneSelectNewListFailureExpected() throws Exception {
|
||||
super.testOneSelectNewList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* 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.test.querycache;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
|
||||
public class PersonName {
|
||||
private String first;
|
||||
private String middle;
|
||||
private String last;
|
||||
|
||||
public PersonName() {}
|
||||
|
||||
public PersonName(String first, String middle, String state) {
|
||||
this.first = first;
|
||||
this.middle = middle;
|
||||
this.last = state;
|
||||
}
|
||||
|
||||
public String getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public void setFirst(String first) {
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
public String getMiddle() {
|
||||
return middle;
|
||||
}
|
||||
|
||||
public void setMiddle(String middle) {
|
||||
this.middle = middle;
|
||||
}
|
||||
|
||||
public String getLast() {
|
||||
return last;
|
||||
}
|
||||
|
||||
public void setLast(String last) {
|
||||
this.last = last;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PersonName name = ( PersonName ) o;
|
||||
|
||||
if ( first != null ? !first.equals( name.first ) : name.first != null ) {
|
||||
return false;
|
||||
}
|
||||
if ( middle != null ? !middle.equals( name.middle ) : name.middle != null ) {
|
||||
return false;
|
||||
}
|
||||
if ( last != null ? !last.equals( name.last ) : name.last != null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = first != null ? first.hashCode() : 0;
|
||||
result = 31 * result + ( last != null ? last.hashCode() : 0 );
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
//$Id: Student.java 9116 2006-01-23 21:21:01Z steveebersole $
|
||||
package org.hibernate.test.querycache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
public class Student {
|
||||
private long studentNumber;
|
||||
private PersonName name;
|
||||
private Course preferredCourse;
|
||||
private Set enrolments = new HashSet();
|
||||
private Map addresses = new HashMap();
|
||||
private List secretCodes = new ArrayList();
|
||||
|
||||
public Student() {}
|
||||
|
||||
public Student(long studentNumber, PersonName name) {
|
||||
this.studentNumber = studentNumber;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public PersonName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(PersonName name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getStudentNumber() {
|
||||
return studentNumber;
|
||||
}
|
||||
|
||||
public void setStudentNumber(long studentNumber) {
|
||||
this.studentNumber = studentNumber;
|
||||
}
|
||||
|
||||
public Map getAddresses() {
|
||||
return addresses;
|
||||
}
|
||||
|
||||
public void setAddresses(Map addresses) {
|
||||
this.addresses = addresses;
|
||||
}
|
||||
|
||||
public Course getPreferredCourse() {
|
||||
return preferredCourse;
|
||||
}
|
||||
|
||||
public void setPreferredCourse(Course preferredCourse) {
|
||||
this.preferredCourse = preferredCourse;
|
||||
}
|
||||
|
||||
public Set getEnrolments() {
|
||||
return enrolments;
|
||||
}
|
||||
|
||||
public void setEnrolments(Set employments) {
|
||||
this.enrolments = employments;
|
||||
}
|
||||
|
||||
public List getSecretCodes() {
|
||||
return secretCodes;
|
||||
}
|
||||
|
||||
public void setSecretCodes(List secretCodes) {
|
||||
this.secretCodes = secretCodes;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || ! ( o instanceof Student ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Student student = ( Student ) o;
|
||||
|
||||
if ( studentNumber != student.getStudentNumber() ) {
|
||||
return false;
|
||||
}
|
||||
if ( name != null ? !name.equals( student.getName() ) : student.getName() != null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = ( int ) ( studentNumber ^ ( studentNumber >>> 32 ) );
|
||||
result = 31 * result + ( name != null ? name.hashCode() : 0 );
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Created on 28-Jan-2005
|
||||
*
|
||||
*/
|
||||
package org.hibernate.test.querycache;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*
|
||||
*/
|
||||
public class StudentDTO {
|
||||
|
||||
private PersonName studentName;
|
||||
private String courseDescription;
|
||||
|
||||
public StudentDTO() { }
|
||||
|
||||
public StudentDTO(PersonName name) {
|
||||
this.studentName = name;
|
||||
}
|
||||
|
||||
public StudentDTO(PersonName name, String description) {
|
||||
this.studentName = name;
|
||||
this.courseDescription = description;
|
||||
}
|
||||
|
||||
public PersonName getName() {
|
||||
return studentName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return courseDescription;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StudentDTO that = ( StudentDTO ) o;
|
||||
|
||||
if ( courseDescription != null ? !courseDescription.equals( that.courseDescription ) : that.courseDescription != null ) {
|
||||
return false;
|
||||
}
|
||||
if ( studentName != null ? !studentName.equals( that.studentName ) : that.studentName != null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = studentName != null ? studentName.hashCode() : 0;
|
||||
result = 31 * result + ( courseDescription != null ? courseDescription.hashCode() : 0 );
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue