[Hibernate-JIRA] Created: (HHH-5929) PooledLoOptimizer in conjunction with SequenceStyleGenerator is not thread-safe
by Robin Sander (JIRA)
PooledLoOptimizer in conjunction with SequenceStyleGenerator is not thread-safe
-------------------------------------------------------------------------------
Key: HHH-5929
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5929
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.1
Environment: Hibernate 3.6.1, Java 6, Mac OS 10.6.6
Reporter: Robin Sander
The generate method of the PooledLoOptimizer introduced in 3.6.1 is not synchronized in difference to the one in PooledOptimizer and in other Optimizer implementations. The problem is that some IdentifierGenerator implementations have themselve a synchronized generate method (like SequenceHiLoGenerator e.g.) and some don't, like the new SequenceStyleGenerator.
According to the javadoc IdentifierGenerator implementations have to be thread-safe. Now I don't know if there is any agreement among the developers whether this thread-safety is to be achieved in the IdentifierGenerator itself or in the Optimizer most of them delegate to but what I know is that SequenceStyleGenerator in conjunction with PooledLoOptimizer is not thread-safe because neither of them guards against concurrent access in any way.
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-6707) One-to-One mapping with foreign key in target table and foreign key being the primary key fails with Oracle
by Florian Rampp (JIRA)
One-to-One mapping with foreign key in target table and foreign key being the primary key fails with Oracle
-----------------------------------------------------------------------------------------------------------
Key: HHH-6707
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6707
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.6
Environment: Oracle 11g, Oracle JDBC 11.2.0.1.0
Reporter: Florian Rampp
Attachments: bugreports-hibernate-oracleUniquePk-1.0-SNAPSHOT-src.zip
When mapping a one-to-one parent/child relationship with the foreign key being in the child table and forming its primary key, in addition to the primary key definition, a unique constraint is generated (due to the one-to-one inverse mapping). A unique constraint and a primary key definition on the same column is not accepted by Oracle. The error is "ORA-02261: such unique or primary key already exists in the table" when creating the schema.
The key entities:
{code:java}
@Entity
public class Parent {
@Id
Long id;
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parent")
Child child;
}
@Entity
public class Child implements Serializable {
@Id
@OneToOne(optional = false)
private Parent parent;
}
{code}
The resulting DDL is:
{code:sql}
create table Child (
parent_id number(19,0) not null,
primary key (parent_id),
unique (parent_id)
)
{code}
This issue is similar to https://hibernate.onjira.com/browse/HBX-978. But I refiled it here since I consider it to be a bug in Hibernate core. Also, I provided a test case that can be used for regression tests. It needs to be executed with the arguments {{-Dhibernate.connection.username=<USERNAME> -Dhibernate.connection.password=<PASSWORD> -Dhibernate.connection.url=<JDBC_URL>}}.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 4 months
[Hibernate-JIRA] Created: (HHH-2158) incorrect hql query on one-to-one with property-ref
by Sebastien Cesbron (JIRA)
incorrect hql query on one-to-one with property-ref
----------------------------------------------------
Key: HHH-2158
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2158
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.ga
Environment: hibernate 3.2.0.ga with firebird 1.5.3 and jaybird 1.5.5 driver on windows XP
Reporter: Sebastien Cesbron
Attachments: testhib.zip
I have a one-to-one relationship with property-ref between Master and Slave2.
I want to find all Master instances that have a null Slave2 instance associated.
To do so my query is
select master from Master master where master.slave2 is null
The sql generated is
select master0_.oid as oid0_, master0_.libelle as libelle0_ from Master master0_ where master0_.oid is null
which seems incorrect. It checks here Master instances with null id (config files are listed below).
If I do my query like this
select master from Master master where master.slave2.oid is null
the generated sql is ok :
select master0_.oid as oid0_, master0_.libelle as libelle0_ from Master master0_, Slave2 slave2x1_ where master0_.oid=slave2x1_.myMaster and (slave2x1_.oid is null)
I have attached a small eclipse project that reproduces the problem
This problem may-be related to the one I have submitted as issue HHH-1849
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-6829) PooledLoOptimizer.generate() should be synchronized
by Manuel Dominguez Sarmiento (JIRA)
PooledLoOptimizer.generate() should be synchronized
---------------------------------------------------
Key: HHH-6829
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6829
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.8
Reporter: Manuel Dominguez Sarmiento
Priority: Critical
We recently switched to this ID generation optimizer in our highly concurrent production platform, and began getting random id / PK collision errors very often.
Checking the code, it's pretty obvious that the problem lies with generate() not being synchronized. All other optimizers (PooledOptimizer, LegacyHiLoAlgorithmOptimizer, HiLoOptimizer, etc.) are synchronized - PooledLoOptimizer should be as well.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 4 months
[Hibernate-JIRA] Created: (HBX-948) org.hibernate.connection.DriverManagerConnectionProvider - problem closing pooled connection
by Sathish P (JIRA)
org.hibernate.connection.DriverManagerConnectionProvider - problem closing pooled connection
--------------------------------------------------------------------------------------------
Key: HBX-948
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-948
Project: Hibernate Tools
Issue Type: Bug
Components: consoleconfiguration
Affects Versions: 3.1.beta5
Environment: Eclipse
Reporter: Sathish P
WARN Finalizer org.hibernate.connection.DriverManagerConnectionProvider - problem closing pooled connection
java.sql.SQLException: Io exception: Socket closed
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:481)
at oracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:1203)
at org.hibernate.connection.DriverManagerConnectionProvider.close(DriverManagerConnectionProvider.java:152)
at org.hibernate.connection.DriverManagerConnectionProvider.finalize(DriverManagerConnectionProvider.java:142)
at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
at java.lang.ref.Finalizer.access$100(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-5719) Applying projection to criteria with restricted subcriterias generates wrong SQL
by Victor Cherkassky (JIRA)
Applying projection to criteria with restricted subcriterias generates wrong SQL
--------------------------------------------------------------------------------
Key: HHH-5719
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5719
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.2.0.ga
Environment: Hibernate 3.2.0 GA
Reporter: Victor Cherkassky
Priority: Minor
Detailed issue description and solution is here http://facingtech.blogspot.com/2010_09_01_archive.html
I will describe only the technical aspect of the issue here.
Considuer the following model.
There is an entity {{User}}, which is in relation with {{Workplace}}. While {{Workplace}} has an {{Activity}} (the purpose of this workplace). Each {{Activity}} has a collection of {{Description}} entities ({{Description}} entities are just the same {{Activity}} description translated into several languages, thus having locale property).
Result of the query should look like this:
||User.name||Workplace.name||Activity.code||Description.text||
|John|Main office|R|Research|
|Polly|Main office|R|Research|
|Craig|Main office|R|Research|
Here is the criteria for getting that result:
{code}
Criteria criteria = session.createCriteria(User.class);
criteria.createAlias("workplace.activity.descriptions", "descriptionsAlias", Criteria.INNER_JOIN);
criteria.add(Restrictions.eq("descriptionsAlias.locale", "en_US"));
criteria.list();
{code}
It works just fine. Produces the table shown above and generates SQL like this:
{code}
select
this_.id as id18_3_,
this_.name as name18_3_,
this_.workplaceId as workplac3_18_3_,
workplace3_.id as id111_0_,
workplace3_.activityId as activityId111_0_,
workplace3_.name as name111_0_,
activity4_.id as id114_1_,
activity4_.code as code114_1_,
descriptio1_.id as id24_2_,
descriptio1_.locale as locale24_2_,
descriptio1_.text as text24_2_
from
user this_
left outer join
workplace workplace3_
on this_.workplaceId=workplace3_.id
left outer join
activity activity4_
on workplace3_.activityId=activity4_.id
inner join
description descriptio1_
on activity4_.id=descriptio1_.activityId
where
descriptio1_.locale=?
{code}
While if you want paging, you should make a rowcount projection first, so your query will look like this:
{code}
Criteria criteria = this.sessionFactory.getCurrentSession().createCriteria(User.class);}}
criteria.createAlias("workplace.activity.descriptions", "descriptionsAlias", criteria.INNER_JOIN);
criteria.add(Restrictions.eq("descriptionsAlias.locale", "en_US"));
criteria.setProjection(Projections.rowCount());
Integer rowCount = (Integer) criteria.uniqueResult();
{code}
And you expect Hibernate to produce this SQL:
{code}
select
count(*) as y0_
from
user this_
left outer join
workplace workplace3_
on this_.workplaceId=workplace3_.id
left outer join
activity activity4_
on workplace3_.activityId=activity4_.id
inner join
description descriptio1_
on activity4_.id=descriptio1_.activityId
where
descriptio1_.locale=?
{code}
But the SQL produced is this:
{code}
select
count(*) as y0_
from
user this_
where
descriptio1_.locale=?
{code}
I suppose that this is a bug, because you expect one behavior, while you get another. I don't think, that this is a big deal, but when you experience such an issue, it is time consuming to get it fixed.
Here is a workaround (or fix) of the issue. You should always assign aliases to all associated "links" of the "entities chain" of the path to an entity you want to restrict if you use projections. In other words, if you have anything in where clause and you are using projections, you should assign aliases to all associations between root entity and the entity, fields of which are used in where clause.
This criteria
{code}
Criteria criteria = this.sessionFactory.getCurrentSession().createCriteria(User.class);
criteria.createAlias("workplace", "workplaceAlias");
criteria.createAlias("workplaceAlias.activity", "activityAlias");
criteria.createAlias("activityAlias.descriptions", "descriptionsAlias", Criteria.INNER_JOIN);
criteria.add(Restrictions.eq("descriptionsAlias.locale", "en_US"));
criteria.setProjection(Projections.rowCount());
Integer rowCount = (Integer) criteria.uniqueResult();
{code}
Produces the right result
{code}
select
count(*) as y0_
from
user this_
inner join
workplace workplacea1_
on this_.workplaceId=workplacea1_.id
inner join
activity activityal2_
on workplacea1_.activityId=activityal2_.id
inner join
description descriptio3_
on activityal2_.id=descriptio3_.activityId
where
descriptio3_.locale=?
{code}
--
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, 4 months
[Hibernate-JIRA] Created: (OGM-112) ConcurrentModificationException while loading associations under load
by Sanne Grinovero (JIRA)
ConcurrentModificationException while loading associations under load
---------------------------------------------------------------------
Key: OGM-112
URL: http://opensource.atlassian.com/projects/hibernate/browse/OGM-112
Project: Hibernate OGM
Issue Type: Bug
Reporter: Sanne Grinovero
{quote}class: class java.util.ConcurrentModificationException
cause: null
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
at java.util.HashMap$KeyIterator.next(HashMap.java:828)
at java.util.AbstractCollection.addAll(AbstractCollection.java:305)
at org.hibernate.ogm.datastore.spi.Association.getKeys(Association.java:132)
at org.hibernate.ogm.loader.OgmLoader.getResultSet(OgmLoader.java:417)
at org.hibernate.ogm.loader.OgmLoader.doQuery(OgmLoader.java:248)
at org.hibernate.ogm.loader.OgmLoader.doQueryAndInitializeNonLazyCollections(OgmLoader.java:215)
at org.hibernate.ogm.loader.OgmLoader.loadCollection(OgmLoader.java:185)
at org.hibernate.ogm.loader.OgmBasicCollectionLoader.initialize(OgmBasicCollectionLoader.java:42)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:622)
at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:82)
at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1606)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:379)
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:112)
at org.hibernate.collection.internal.PersistentSet.iterator(PersistentSet.java:180){quote}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 4 months