[Hibernate-JIRA] Created: (HHH-7290) The JDBC Driver will not be loaded in some case
by chiwei (JIRA)
The JDBC Driver will not be loaded in some case
-----------------------------------------------
Key: HHH-7290
URL: https://hibernate.onjira.com/browse/HHH-7290
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.1.2
Environment: hibernate 4.1.2
tomcat 7.0.27
mysql-connector 5.1.19
Reporter: chiwei
Before v4.1.2,The method "org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure" use "Class.forName" load JDBC Driver.
The version 4.1.2, this method use "serviceRegistry.getService(ClassLoaderService.class)" get a instance of org.hibernate.service.classloading.internal.ClassLoaderServiceImpl, and call method "classForName" to load JDBC Driver.
The method "classForName" use classloader.loadClass load JDBC Driver. There are some different to "Class.forName".
"classForName" only load class to memory.
"Class.forName" load class to memory and call the class's static block.
The JDBC Driver must be register itself to JDBC's DriverManager at the static block. because "classForName" not call static block, JDBC Driver will not register.
JDBC4.0 has SPM, so sometimes JDBC can find and register driver automatic, but the SPM seek class is different from classloader, so classloader can fina a class, SPM maybe miss.
If SPM can not find the driver, SPM is not work, and hibernate will not get connection.
e.g. the JDBC Driver jar put to <tomcat>\lib, SPM will not find the driver(default config of tomcat), so the driver not register. the "classForName" can find and load the driver, but the driver not register too, hibernate can not get a connection.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[Hibernate-JIRA] Created: (HHH-7292) Dirty check for CustomEntityDirtynessStrategy gets bypassed with current implemenation
by Shawn Clowater (JIRA)
Dirty check for CustomEntityDirtynessStrategy gets bypassed with current implemenation
--------------------------------------------------------------------------------------
Key: HHH-7292
URL: https://hibernate.onjira.com/browse/HHH-7292
Project: Hibernate ORM
Issue Type: Improvement
Components: core
Affects Versions: 4.1.2
Environment: N/A
Reporter: Shawn Clowater
When initially testing the new functionality around the CustomEntityDirtynessStrategy it seemed to work pretty well to be able to identify what properties are dirty in the event that the entity is dirty. However, I was noticing that the default checking was kicking in if my strategy was returning null for the dirty properties.
I believe the problem lies in the dirty check in the EntityEntry class
{code}
public boolean requiresDirtyCheck(Object entity) {
return isModifiableEntity()
&& ( getPersister().hasMutableProperties() || ! isUnequivocallyNonDirty( entity ) );
}
@SuppressWarnings( {"SimplifiableIfStatement"})
private boolean isUnequivocallyNonDirty(Object entity) {
if ( getPersister().getInstrumentationMetadata().isInstrumented() ) {
// the entity must be instrumented (otherwise we cant check dirty flag) and the dirty flag is false
return ! getPersister().getInstrumentationMetadata().extractInterceptor( entity ).isDirty();
}
final CustomEntityDirtinessStrategy customEntityDirtinessStrategy =
persistenceContext.getSession().getFactory().getCustomEntityDirtinessStrategy();
if ( customEntityDirtinessStrategy.canDirtyCheck( entity, getPersister(), (Session) persistenceContext.getSession() ) ) {
return ! customEntityDirtinessStrategy.isDirty( entity, getPersister(), (Session) persistenceContext.getSession() );
}
return false;
}
{code}
Basically, any entity that has mutable properties will effectively end up bypassing the custom dirty checking.
The proposed solution is to do the custom checking initially and then default to the hasMutableProperties as a fallback in order to perform the default checking.
I'll hopefully get some cycles for this prior to 4.1.4
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[Hibernate-JIRA] Created: (HHH-5743) Criteria isMember() creates broken SQL in joined queries
by David Momper (JIRA)
Criteria isMember() creates broken SQL in joined queries
--------------------------------------------------------
Key: HHH-5743
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5743
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.0, 3.6.1
Environment: Hibernate 3.6.0,3.6.1, all databases
Reporter: David Momper
Priority: Critical
Attachments: Test.zip
This problem occurred both when using Oracle, or Derby. I assume it occurs for all databases. I also ran my test case with EclipseLink, and the test passed.
A criteria query like this:
{quote}
CriteriaQuery<Group> groupQuery = cb.createQuery(Group.class);
Root<Group> gRoot = groupQuery.from(Group.class);
//Get all groups whose leader's name is John, and has a valid visa for given country
groupQuery.where(cb.and(
cb.like(gRoot.get(Group_.groupLeader)
.get(Person_.personName), "%John%"),
cb.isMember(country,
gRoot.get(Group_.groupLeader)
.get(Person_.validVisas)
)
));
{quote}
produces the following query:
{quote}
select
group0_.GROUP_ID as GROUP1_2_,
group0_.LEADER_ID as LEADER3_2_,
group0_.GROUP_NAME as GROUP2_2_
from
GROUPS group0_,
PERSON person1_
where
group0_.LEADER_ID=person1_.PERSON_ID
and (
person1_.PERSON_NAME like ?
)
and (
? in (
select
person1_.PERSON_ID
from
PERSON person1_
)
)
{quote}
The query fails because a (character) country code is being checked for inclusion in a subquery of (int) person ids.
The subselect in the above query should be on a country, not a person. I think the whole query should look like this:
{quote}
select
group0_.GROUP_ID as GROUP1_2_,
group0_.LEADER_ID as LEADER3_2_,
group0_.GROUP_NAME as GROUP2_2_
from
GROUPS group0_,
PERSON person1_
where
group0_.LEADER_ID=person1_.PERSON_ID
and (
person1_.PERSON_NAME like ?
)
and (
? in (
select
country3_.COUNTRY_CODE
from
PERSON person1_,
PERSON_COUNTRY_VISA validvisas2_,
COUNTRY country3_
where
group0_.LEADER_ID=person1_.PERSON_ID
and person1_.PERSON_ID=validvisas2_.PERSON_ID
and validvisas2_.COUNTRY_CODE=country3_.COUNTRY_CODE
)
)
{quote}
--
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
12 years, 8 months
[Hibernate-JIRA] Created: (HHH-7291) Allow the use of HQL in discriminator formula's
by Rowan Massey (JIRA)
Allow the use of HQL in discriminator formula's
-----------------------------------------------
Key: HHH-7291
URL: https://hibernate.onjira.com/browse/HHH-7291
Project: Hibernate ORM
Issue Type: Improvement
Components: query-hql
Affects Versions: 4.1.0
Reporter: Rowan Massey
I created a custom SQL function called "bitwiseAnd" for the dialects of both SQLServer and Oracle10g, since we support both databases. I was hoping to use this in my DiscriminatorFormula annotation, however it expects native SQL, which would force me to facilitate the use of one dialect only. Would it be at all possible to use HQL along with custom functions in the discriminator formula?
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[Hibernate-JIRA] Created: (HSEARCH-1113) ExcludeFalse Capability Query by Example Example
by Uday Kari (JIRA)
ExcludeFalse Capability Query by Example Example
------------------------------------------------
Key: HSEARCH-1113
URL: https://hibernate.onjira.com/browse/HSEARCH-1113
Project: Hibernate Search
Issue Type: Improvement
Components: engine
Affects Versions: 4.1.0.Final
Environment: all
Reporter: Uday Kari
Priority: Minor
In web form development, checkboxes are mapped to booleans properties. When using a form to conduct Query By Example, the results should exclude un-checked or false properties. I have already fixed this for my application, here is the code...you are welcome to use it.
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. 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 Inc.
*
* 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.criterion;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.hibernate.Criteria;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.engine.TypedValue;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.CompositeType;
import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
/**
* Support for query by example.
* <pre>
* List results = session.createCriteria(Parent.class)
* .add( Example.create(parent).ignoreCase() )
* .createCriteria("child")
* .add( Example.create( parent.getChild() ) )
* .list();
* </pre>
* "Examples" may be mixed and matched with "Expressions" in the same <tt>Criteria</tt>.
* @see org.hibernate.Criteria
* @author Gavin King
*/
public class Example implements Criterion {
private final Object entity;
private final Set excludedProperties = new HashSet();
private PropertySelector selector;
private boolean isLikeEnabled;
private Character escapeCharacter;
private boolean isIgnoreCaseEnabled;
private MatchMode matchMode;
/**
* A strategy for choosing property values for inclusion in the query
* criteria
*/
public static interface PropertySelector extends Serializable {
public boolean include(Object propertyValue, String propertyName, Type type);
}
private static final PropertySelector NOT_NULL = new NotNullPropertySelector();
private static final PropertySelector ALL = new AllPropertySelector();
private static final PropertySelector NOT_NULL_OR_ZERO = new NotNullOrZeroPropertySelector();
////////////////////////////////////////////////////////////
// Uday Edits
//
private static final PropertySelector NOT_FALSE = new NotFalsePropertySelector();
static final class NotFalsePropertySelector implements PropertySelector
{
public boolean include(Object object, String propertyName, Type type)
{
if (object == null)
{
return false;
}
else if (object instanceof Boolean)
{
return ((Boolean) object).booleanValue();
}
else
{
return true;
}
}
}
/**
* Exclude false-valued properties
*/
public Example excludeFalse() {
setPropertySelector(NOT_FALSE);
return this;
}
//
// End
/////////////////////////////////////////
[...]
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[Hibernate-JIRA] Created: (HHH-7289) NPE when using JDBC connection pool Proxool
by chiwei (JIRA)
NPE when using JDBC connection pool Proxool
-------------------------------------------
Key: HHH-7289
URL: https://hibernate.onjira.com/browse/HHH-7289
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.0.0.Final
Environment: hibernate4.1.2
Reporter: chiwei
Attachments: ProxoolConnectionProviderTestCase.java
org.hibernate.service.jdbc.connections.internal.ProxoolConnectionProvider.java (hibernate-proxool-4.1.2.Final.jar) does not implement interface org.hibernate.service.spi.Configurable
so the method configure is never called, this leads to a NPE while building the SessionFactory.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months