[Hibernate-JIRA] Created: (HV-363) HV uses Thread's context class loader to load internal implementation classes
by Sanjeeb Sahoo (JIRA)
HV uses Thread's context class loader to load internal implementation classes
-----------------------------------------------------------------------------
Key: HV-363
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-363
Project: Hibernate Validator
Issue Type: Bug
Components: engine
Reporter: Sanjeeb Sahoo
Assignee: Hardy Ferentschik
Priority: Blocker
org.hibernate.validator.engine.resolver.DefaultTraversableResolver uses Thread's context class loader to load JPA_AWARE_TRAVERSABLE_RESOLVER_CLASS_NAME, which is org.hibernate.validator.engine.resolver.JPATraversableResolver. Why? Since one implementation class is looking for another implementation class, should it not use getClass().getClassLoader() instead? The relevant code is given below:
private void detectJPA() {
try {
loadClass( PERSISTENCE_UTIL_CLASS_NAME, this.getClass() );
log.debug( "Found {} on classpath.", PERSISTENCE_UTIL_CLASS_NAME );
}
catch ( ValidationException e ) {
log.debug(
"Cannot find {} on classpath. All properties will per default be traversable.",
PERSISTENCE_UTIL_CLASS_NAME
);
return;
}
try {
@SuppressWarnings( "unchecked" )
Class<? extends TraversableResolver> jpaAwareResolverClass = (Class<? extends TraversableResolver>)
loadClass(JPA_AWARE_TRAVERSABLE_RESOLVER_CLASS_NAME, this.getClass() );
NewInstance<? extends TraversableResolver> newInstance = NewInstance.action( jpaAwareResolverClass, "" );
if ( System.getSecurityManager() != null ) {
jpaTraversableResolver = AccessController.doPrivileged( newInstance );
}
else {
jpaTraversableResolver = newInstance.run();
}
log.info(
"Instantiated an instance of {}.", JPA_AWARE_TRAVERSABLE_RESOLVER_CLASS_NAME
);
}
catch ( ValidationException e ) {
log.info(
"Unable to load or instanciate JPA aware resolver {}. All properties will per default be traversable.",
JPA_AWARE_TRAVERSABLE_RESOLVER_CLASS_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
15 years, 6 months
[Hibernate-JIRA] Created: (HHH-5440) JPA 2.0 CriteriaBuilder API and CollectionOfElements
by Koen Molkenboer (JIRA)
JPA 2.0 CriteriaBuilder API and CollectionOfElements
----------------------------------------------------
Key: HHH-5440
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5440
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.4
Environment: hibernate-core 3.5.4, hibernate-entitymanager 3.5.4, hsqldb 2.0.0, mac os x 10.6, java 1.6.0_20
Reporter: Koen Molkenboer
The situation is as follow:
I have an User class which has a collection of elements which is a Set of Role enum values and I want to search for users which have one of more roles. I want to use the CriteriaBuilder, because I have a search form with a lot of fields which are optional.
The User class:
@Entity
@Table(name = "USERS")
@Access(AccessType.FIELD)
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private Long id;
@Column(name = "USERNAME", unique = true, nullable = false, length = 128)
private String username;
@ElementCollection
@Enumerated(EnumType.STRING)
@Column(name = "ROLE")
@CollectionTable(name = "USER_ROLES", joinColumns = @JoinColumn(name = "USER_ID"))
private Set<Role> roles = new HashSet<Role>();
...
}
The enum Role:
public enum Role {
ROLE_1, ROLE_2, ROLE_3;
}
Creating the query with the CriteriaBuilder
Set<Role> roles = new HashSet<Role>();
roles.add(Role.ROLE_1);
roles.add(Role.ROLE_2);
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<User> criteriaQuery = criteriaBuilder.createQuery(User.class);
Root<User> root = criteriaQuery.from(User.class);
criteriaQuery.where(root.join("roles").in(roles));
TypedQuery<User> query = entityManager.createQuery(criteriaQuery);
query.getResultList();
This is the exception:
java.lang.IllegalArgumentException: Parameter value [ROLE_2] was not matching type [java.util.Set]
at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:360)
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:359)
at org.hibernate.ejb.criteria.CriteriaQueryCompiler$1$1.bind(CriteriaQueryCompiler.java:194)
at org.hibernate.ejb.criteria.CriteriaQueryCompiler.compile(CriteriaQueryCompiler.java:247)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:437)
...
This all works with OpenJPA 2.0.0
--
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
15 years, 6 months
[Hibernate-JIRA] Created: (HHH-2319) StatelessInterceptor
by Max Rydahl Andersen (JIRA)
StatelessInterceptor
--------------------
Key: HHH-2319
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2319
Project: Hibernate3
Type: New Feature
Components: core
Versions: 3.2.1
Reporter: Max Rydahl Andersen
It would make sense to have an Interceptor for StatelessSession to solve the following usecases:
Log/adjust SQL: onPrepareStatement
Proper entityname handling: instantiate/getEntity
Maybe also tx interaction: afterTransationBegin/beforeTransactionCompletion/afterTransactionCompletion
Technically it could be solved by just allowing to pass in a normal interceptor to a StatelessSession and just
document that the state oriented callbacks will not be called. Alternatively we can create a StatelessInterceptor that
only implement the releavant methods and wrap that instance into an internal Interceptor.
--
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
15 years, 6 months