[Hibernate-JIRA] Created: (HHH-5621) NPE (in ReflectHelper.getConstructor) during createQuery without alias with one entity (wich use several tables)
by Félix Gerzaguet (JIRA)
NPE (in ReflectHelper.getConstructor) during createQuery without alias with one entity (wich use several tables)
----------------------------------------------------------------------------------------------------------------
Key: HHH-5621
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5621
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.0.CR2
Environment: Gentoo Linux
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Hibernate 3.6.0.CR2
tested DB: PostgreSQL 8.4, HSQLDB 1.8.0.10
Reporter: Félix Gerzaguet
Priority: Minor
Attachments: TestCaseCreateQueryWithoutAliasNPE.jar
During a session.createQuery like:
Query query6 = session.createQuery("select new Something(id, event, dummyField) " +
"from Something" );
A NPE is thrown:
Exception in thread "main" java.lang.NullPointerException
at org.hibernate.util.ReflectHelper.getConstructor(ReflectHelper.java:343)
at org.hibernate.hql.ast.tree.ConstructorNode.resolveConstructor(ConstructorNode.java:176)
at org.hibernate.hql.ast.tree.ConstructorNode.prepare(ConstructorNode.java:150)
at org.hibernate.hql.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:996)
I join an test case.
All versions of hibernate seems affected (from 3.2.6.ga to 3.6.0.RC2).
This is a minor issue since an easy workaround is available: you just have to use an alias to qualifie the properties
For the preceding example, we will have:
Query query3 = session.createQuery("select new Something(sthg.id, sthg.event, sthg.dummyField) " +
"from Something sthg" );
Possible fix:
As described in the testCase, I fix this by a one character fix:
In org.hibernate.hql.ast.HqlSqlWalker in method isNonQualifiedPropertyRef,
change from
if ( fromElements.size() == 1 ) {
to
if ( fromElements.size() >= 1 ) {
This could means that when a property is not qualified, we leave a chance for this property to be found on the first explicit element of the from clause.
I test this fix on the 3.5.5-Final code and I was able to run the test suite without failures.
I can't think of a test case in which this fix could lead to a regression but I'm not an Hibernate Guru so comments are welcome.
--
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
13 years, 9 months
[Hibernate-JIRA] Created: (HHH-5666) Missing table alias for one column in generated sql
by Jakub Jankowski (JIRA)
Missing table alias for one column in generated sql
---------------------------------------------------
Key: HHH-5666
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5666
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.0-CR-2
Environment: Hibernate 3.5.0-CR-2, MySQL
Reporter: Jakub Jankowski
Column 'desc' in generated sql doesn't have table alias 'announceme0_' (unlike the rest of columns) which genereates error while executing.
Genereted sql:
select announceme0_.announcementID as announce1_1_0_,
announceme0_.oceaneqID as oceaneqID1_0_,
announceme0_.fileName as fileName1_0_,
desc as desc1_0_
from test.announcement announceme0_ where announceme0_.announcementID=1
Mapping for the table:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2010-09-01 12:28:56 by Hibernate Tools 3.1.0.beta4 -->
<hibernate-mapping>
<class name="all.model.Announcement" table="announcement" catalog="test">
<id name="announcementId" type="int">
<column name="announcementID" />
<generator class="assigned" />
</id>
<property name="oceaneqId" type="java.lang.Integer">
<column name="oceaneqID" />
</property>
<property name="fileName" type="string">
<column name="fileName" length="1024" />
</property>
<property name="desc" type="string">
<column name="desc" length="1024" />
</property>
<set name="routeOnAnnouncements" inverse="true">
<key>
<column name="announcementID" />
</key>
<one-to-many class="all.model.RouteOnAnnouncement" />
</set>
</class>
</hibernate-mapping>
There's no such problem with other tables.
--
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
13 years, 9 months
[Hibernate-JIRA] Created: (HHH-3524) setFetchMode ignored if using createCriteria
by Peter Weemeeuw (JIRA)
setFetchMode ignored if using createCriteria
--------------------------------------------
Key: HHH-3524
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3524
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5, Oracle 8
Reporter: Peter Weemeeuw
Hi,
It seems that criteria.setFetchMode gets ignored if you combine it with createCriteria to add a restriction.
This works as expected:
DetachedCriteria c = DetachedCriteria.forClass(MenuItem.class);
c.setFetchMode("menuItemSubscriptions", FetchMode.JOIN);
But in this case the join doesn't happen (and I get a LazyInstantiationException further on).
DetachedCriteria c = DetachedCriteria.forClass(MenuItem.class);
c.setFetchMode("menuItemSubscriptions", FetchMode.JOIN);
c.createCriteria("menuItemSubscriptions").add(
Restrictions.eq("location", "B")
);
This does not happen if I set lazy="false" in the mappings
file.
Regards,
Peter
--
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
13 years, 9 months
[Hibernate-JIRA] Created: (HV-384) Performence problem when using programatic constrain declaration
by Jan Cuzy (JIRA)
Performence problem when using programatic constrain declaration
----------------------------------------------------------------
Key: HV-384
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-384
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 4.1.0.Final
Environment: Java 1.6, OSGi Equinox
Reporter: Jan Cuzy
Assignee: Hardy Ferentschik
I'm using the programmatic API to declare the constrains on class.
{noformat} ConstraintMapping constraintMapping = ...
HibernateValidatorConfiguration config = ...
config.addMapping(constraintMapping);
ValidatorFactory factory = config.buildValidatorFactory();{noformat}
Right now I have 73 with 745 configured constrains on them (This is rather beginning of the project, in the future numbers will be higher). It takes approx. 6 seconds to create the validator factory. I was investigating a bit and found a method initProgrammaticConfiguration in ValidatorFactoryImpl class, which calls vary often the method getConstraintConfig() on the ConstraintMapping class.
This method creates always new
{noformat}<A extends Annotation> Map<Class<?>, List<ConstraintDefWrapper<?>>>{noformat}
based on values in its member variable
{noformat} private final Map<Class<?>, List<ConstraintDef<?>>> constraintConfig{noformat}
Is there any problem to cache the created map as a meber in the ConstraintMapping class?
I've done
{noformat}
public class ConstraintMapping {
private final Map<Class<?>, List<ConstraintDef<?>>> constraintConfig;
private Map<Class<?>, List<ConstraintDefWrapper<?>>> newDefinitions;
...
{noformat}
then
{noformat} public final <A extends Annotation> Map<Class<?>, List<ConstraintDefWrapper<?>>> getConstraintConfig() {
*if (newDefinitions == null) {*
*newDefinitions = new HashMap<Class<?>, List<ConstraintDefWrapper<?>>>();*
for (Map.Entry<Class<?>, List<ConstraintDef<?>>> entry : constraintConfig.entrySet()) {
List<ConstraintDefWrapper<?>> newList = new ArrayList<ConstraintDefWrapper<?>>();
for (ConstraintDef<?> definition : entry.getValue()) {
Class<?> beanClass = definition.beanType;
@SuppressWarnings("unchecked")
ConstraintDefWrapper<A> defAccessor = new ConstraintDefWrapper<A>(beanClass,
(Class<A>) definition.constraintType, definition.property, definition.elementType,
definition.parameters, this);
newList.add(defAccessor);
}
newDefinitions.put(entry.getKey(), newList);
}
*}*
return newDefinitions;
}{noformat}
and then maybe also
{noformat} protected final void addConstraintConfig(ConstraintDef<?> definition) {
Class<?> beanClass = definition.beanType;
configuredClasses.add(beanClass);
if (constraintConfig.containsKey(beanClass)) {
constraintConfig.get(beanClass).add(definition);
}
else {
List<ConstraintDef<?>> definitionList = new ArrayList<ConstraintDef<?>>();
definitionList.add(definition);
constraintConfig.put(beanClass, definitionList);
*newDefinitions = null;*
}
}
{noformat}
and the time which is needed to create the factory is 200ms.
--
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
13 years, 9 months