HHH-5440 - Joined collection expressions not properly "rendered" in JPA Criteria queries
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20193 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
fa587d4da7
commit
60bceb24f7
|
@ -118,6 +118,11 @@ public abstract class AbstractFromImpl<Z,X>
|
|||
return getAlias();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
|
||||
return renderProjection( renderingContext );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -38,8 +38,10 @@ import javax.persistence.criteria.Root;
|
|||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.ejb.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.ejb.metamodel.Phone;
|
||||
import org.hibernate.ejb.metamodel.Product;
|
||||
import org.hibernate.ejb.metamodel.Product_;
|
||||
import org.hibernate.ejb.test.mapping.Phone_;
|
||||
import org.hibernate.impl.AbstractQueryImpl;
|
||||
|
||||
/**
|
||||
|
@ -285,4 +287,18 @@ public class ExpressionsTest extends AbstractMetamodelSpecificTest {
|
|||
em.getTransaction().commit();
|
||||
em.close();
|
||||
}
|
||||
|
||||
public void testJoinedElementCollectionValuesInTupleList() {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
CriteriaQuery<Phone> criteria = builder.createQuery( Phone.class );
|
||||
Root<Phone> from = criteria.from( Phone.class );
|
||||
criteria.where(
|
||||
from.join( "types" )
|
||||
.in( Collections.singletonList( Phone.Type.WORK ) )
|
||||
);
|
||||
em.createQuery( criteria ).getResultList();
|
||||
em.getTransaction().commit();
|
||||
em.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
*/
|
||||
package org.hibernate.ejb.metamodel;
|
||||
|
||||
import java.util.Set;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
|
@ -38,10 +40,13 @@ import javax.persistence.Table;
|
|||
@Entity
|
||||
@Table(name = "PHONE_TABLE")
|
||||
public class Phone implements java.io.Serializable {
|
||||
public enum Type { LAND_LINE, CELL, FAX, WORK, HOME }
|
||||
|
||||
private String id;
|
||||
private String area;
|
||||
private String number;
|
||||
private Address address;
|
||||
private Set<Type> types;
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
@ -96,4 +101,13 @@ public class Phone implements java.io.Serializable {
|
|||
public void setAddress(Address a) {
|
||||
address = a;
|
||||
}
|
||||
|
||||
@ElementCollection
|
||||
public Set<Type> getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(Set<Type> types) {
|
||||
this.types = types;
|
||||
}
|
||||
}
|
|
@ -1,23 +1,8 @@
|
|||
### direct log messages to stdout ###
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
|
||||
### direct messages to file hibernate.log ###
|
||||
log4j.appender.file=org.apache.log4j.FileAppender
|
||||
log4j.appender.file.File=hibernate.log
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
|
||||
### direct messages to socket - chainsaw ###
|
||||
log4j.appender.socket=org.apache.log4j.net.SocketAppender
|
||||
log4j.appender.socket.remoteHost=localhost
|
||||
log4j.appender.socket.port=4560
|
||||
log4j.appender.socket.locationInfo=true
|
||||
|
||||
### set log levels - for more verbose logging change 'info' to 'debug' ###
|
||||
|
||||
log4j.rootLogger=warn, stdout
|
||||
|
||||
log4j.logger.org.hibernate=debug
|
||||
|
|
Loading…
Reference in New Issue