[Hibernate-JIRA] Created: (HHH-5051) JPA 2 Criteria Query with Object as Parameter not Working
by Guido Müller (JIRA)
JPA 2 Criteria Query with Object as Parameter not Working
---------------------------------------------------------
Key: HHH-5051
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5051
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.0-CR-2
Reporter: Guido Müller
Priority: Blocker
The problem is with this scenario:
2 Entity classes A and B
We have a 1:N relation between A (N) and B (1)
This test fails:
I get one instance of B with the entity manager find method.
I query the database with JPA 2 query to get a list of all instances of A that have the many-to-one property equals the instance got from the 1st step.
Code:
EntityManager em = ...
B b = em.find(B.class, 1L);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<A> q = cb.createQuery(A.class);
Root<A> p = q.from(A.class);
q.select(p).where(cb.equal(p.get(A_.b), b));
List<A> l = em.createQuery(q).getResultList();
em.close();
This does not work but it should. It works properly with EclipseLink. In Hibernate I get this to work when I provide b.getId() as Parameter. But this is not correct!
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (HHH-4965) Bug in org.hibernate.ejb.QueryImpl
by jean-claude cote (JIRA)
Bug in org.hibernate.ejb.QueryImpl
----------------------------------
Key: HHH-4965
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4965
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.0-CR-1
Reporter: jean-claude cote
Priority: Minor
Emmanuel
There seems to be a bug in the QueryImpl class in the method
extractParameterInfo()
Here's what I've done:
I create an equal predicate using a Path to House.address and a Address value.
@Entity
class House
{
@Type(type="jc.AddressUserType")
@Columns(columns={@Column(name="address")})
Address address;
In the extractParameterInfo() method there is a loop that gets the
javaType from a namedParameterTypeRedefinition.
It gets the javaType (Address.class) then since it is not null tries
to find the hibernate Type using the TypeFactory.heuristicType()
method. But given a javaType this will only work for strings, int,
double etc. What is passed in is an Address not an AddressUserType.
The huristicType actually returns an hibernate SerializableType and
resets the descriptor which was correct in the first place.
I've fix this for myself my just commenting out the call to
resetExpectedType but there must be a good reason why this call is
made there correct?
Thanks
Jean-Claude
@SuppressWarnings({ "unchecked", "RedundantCast" })
private void extractParameterInfo(Map<String,Class>
namedParameterTypeRedefinition) {
if ( ! AbstractQueryImpl.class.isInstance( query ) ) {
throw new IllegalStateException( "Unknown query type for parameter
extraction" );
}
HashSet<Parameter<?>> parameters = new HashSet<Parameter<?>>();
AbstractQueryImpl queryImpl = AbstractQueryImpl.class.cast( query );
// extract named params
for ( String name : (Set<String>)
queryImpl.getParameterMetadata().getNamedParameterNames() ) {
final NamedParameterDescriptor descriptor =
queryImpl.getParameterMetadata().getNamedParameterDescriptor( name );
Class javaType = namedParameterTypeRedefinition.get( name );
if ( javaType != null ) {
descriptor.resetExpectedType(
TypeFactory.heuristicType( javaType.getName() )
);
}
else if ( descriptor.getExpectedType() != null ) {
javaType = descriptor.getExpectedType().getReturnedClass();
}
final ParameterImpl parameter = new ParameterImpl( name, javaType );
parameters.add( parameter );
if ( descriptor.isJpaStyle() ) {
if ( jpaPositionalIndices == null ) {
jpaPositionalIndices = new HashSet<Integer>();
}
jpaPositionalIndices.add( Integer.valueOf( name ) );
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (HSEARCH-320) Hibernate Search conflicts with Spring's class path scanning
by Paul Middelkoop (JIRA)
Hibernate Search conflicts with Spring's class path scanning
------------------------------------------------------------
Key: HSEARCH-320
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-320
Project: Hibernate Search
Issue Type: Bug
Affects Versions: 3.1.0.GA, 3.1.0.CR1
Reporter: Paul Middelkoop
Hibernate Search conflicts with Spring's class path scanning. When Hibernate Search is on the classpath Spring throws an exception while reading annotation metadata.
3.1.0 Beta1 and 3.0.x versions had no problems.
Stacktrace:
Caused by: java.lang.ArrayIndexOutOfBoundsException: 50432
at org.springframework.asm.ClassReader.readUTF8(Unknown Source)
at org.springframework.asm.ClassReader.accept(Unknown Source)
at org.springframework.asm.ClassReader.accept(Unknown Source)
at org.springframework.core.type.classreading.SimpleMetadataReader.getAnnotationMetadata(SimpleMetadataReader.java:55)
at org.springframework.core.type.filter.AnnotationTypeFilter.matchSelf(AnnotationTypeFilter.java:68)
at org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter.match(AbstractTypeHierarchyTraversingFilter.java:55)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isCandidateComponent(ClassPathScanningCandidateComponentProvider.java:224)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:182)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:201)
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:85)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1255)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1245)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (HHH-4864) "Cannot read files twice on NativeScanner" exception when using multiple persistence.xml
by Bouiaw (JIRA)
"Cannot read files twice on NativeScanner" exception when using multiple persistence.xml
----------------------------------------------------------------------------------------
Key: HHH-4864
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4864
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Beta-3
Reporter: Bouiaw
When subclassing DefaultPersistenceUnitManager as described in http://ancientprogramming.blogspot.com/2007/05/multiple-persistencexml-fi... in order to have my entities in different jars, Hibernate 3.5-Beta3 throw the following exception (it worked with previous version of Hibernate) :
java.lang.RuntimeException: error trying to scan <jar-file>: file:/Users/bouiaw/resthub/resthub-core/target/classes/
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:700)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:465)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:165)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1457)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1397)
... 51 more
Caused by: org.hibernate.AssertionFailure: Cannot read files twice on NativeScanner
at org.hibernate.ejb.packaging.NativeScanner.getFilesInJar(NativeScanner.java:168)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:393)
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:697)
... 57 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 3 months