[Hibernate-JIRA] Created: (HHH-5824) Poor multithread performance in SessionFactoryImpl.getQueryCache method
by Alexey Romanchuk (JIRA)
Poor multithread performance in SessionFactoryImpl.getQueryCache method
-----------------------------------------------------------------------
Key: HHH-5824
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5824
Project: Hibernate Core
Issue Type: Bug
Components: caching (L2)
Affects Versions: 3.6.0
Reporter: Alexey Romanchuk
Synchronize all access to Map is multithreading bottleneck. ConcurrentHashMap or write syncronization can solve this issue.
Here it is how SessionFactoryImpl.getQueryCache can be implemented:
{code}
public QueryCache getQueryCache(String regionName) throws HibernateException {
if ( regionName == null ) {
return getQueryCache();
}
if ( !settings.isQueryCacheEnabled() ) {
return null;
}
QueryCache currentQueryCache = ( QueryCache ) queryCaches.get( regionName );
if ( currentQueryCache == null ) {
synchronized ( allCacheRegions ) {
currentQueryCache = ( QueryCache ) queryCaches.get( regionName );
if ( currentQueryCache == null ) {
currentQueryCache = settings.getQueryCacheFactory().getQueryCache( regionName, updateTimestampsCache, settings, properties );
queryCaches.put( regionName, currentQueryCache );
allCacheRegions.put( currentQueryCache.getRegion().getName(), currentQueryCache.getRegion() );
}
}
}
return currentQueryCache;
}
{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
13 years, 11 months
[Hibernate-JIRA] Created: (HHH-5550) Hibernate.createBlob() fails when used in current_session_context_class=thread mode
by Zemian Deng (JIRA)
Hibernate.createBlob() fails when used in current_session_context_class=thread mode
-----------------------------------------------------------------------------------
Key: HHH-5550
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5550
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.5
Reporter: Zemian Deng
See https://forum.hibernate.org/viewtopic.php?f=1&t=1004366
Here is a unit test failed case:
{code:java}
package deng.hibernate.examples.blob;
import org.hibernate.*;
import org.hibernate.cfg.*;
import org.junit.Test;
public class HibernateCreateBlobFailedCase {
@Test
public void createBlob() {
Configuration cfg = new Configuration();
SessionFactory sessionFactory = cfg.configure().buildSessionFactory();
Session session = sessionFactory.getCurrentSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
byte[] blobBytes = new byte[]{};
Hibernate.createBlob(blobBytes, session);
} catch (Throwable e) {
tx.rollback();
throw new RuntimeException(e);
} finally {
sessionFactory.close();
}
}
}
{code}
Set hibernate.cfg.xml with thread session context
{code:xml}
...
<property name="current_session_context_class">thread</property>
...
{code}
You will get this stack trace
{noformat}
java.lang.RuntimeException: java.lang.ClassCastException: $Proxy4 cannot be cast to org.hibernate.engine.jdbc.LobCreationContext
at deng.hibernate.examples.blob.HibernateCreateBlobFailedCase.createBlob(HibernateCreateBlobFailedCase.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassCastException: $Proxy4 cannot be cast to org.hibernate.engine.jdbc.LobCreationContext
at org.hibernate.Hibernate.getLobCreator(Hibernate.java:502)
at org.hibernate.Hibernate.getLobCreator(Hibernate.java:498)
at org.hibernate.Hibernate.createBlob(Hibernate.java:494)
at deng.hibernate.examples.blob.HibernateCreateBlobFailedCase.createBlob(HibernateCreateBlobFailedCase.java:21)
... 22 more
{noformat}
As described in forum, this problem occurred because the session object we get using {{sessionFactory.getCurrentSession();}} is an wrapped ThreadLocalSessionContext instance that can not be cast into LobCreationContext. There is no easy way to unwrap and get the original session object, to pass to createBlob method.
--
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, 11 months
[Hibernate-JIRA] Created: (HHH-5430) Better Firebird support - temp tables, short column names
by Martin Černý (JIRA)
Better Firebird support - temp tables, short column names
---------------------------------------------------------
Key: HHH-5430
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5430
Project: Hibernate Core
Issue Type: Improvement
Components: core
Affects Versions: 3.5.3
Reporter: Martin Černý
Priority: Minor
Attachments: Firebird21Dialect.java, GenericLengthLimitedNamingStrategy.java, LengthLimitedComponentSafeNamingStrategy.java
Sorry for not posting in some more concise format or joining the development in an official way, however I hope it still helps.
In my quest to make Firebird work with my Hibernate/JPA project I have developed two helper classes that (especially the first one) might as well be incorporated in the Hibernate.
First I have subclassed FirebirdDialect to make use of temporary table support in Firebird 2.1 (this had blocked some of the JPA features)
Then I have subclassed NamingStrategy to create a generic strategy that forces all the database identifiers to conform to certain length. This is needed since Firebird does not work with column and table names longer than 30 chars. Although I am not certain, if this should be part of Hibernate.
The class I created are attached, their utility is up to the consideration of the community
--
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, 11 months
[Hibernate-JIRA] Created: (HHH-5860) Sql Join clauses generated in incorrect order when implied joins are created from the select clause
by Mike Q (JIRA)
Sql Join clauses generated in incorrect order when implied joins are created from the select clause
---------------------------------------------------------------------------------------------------
Key: HHH-5860
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5860
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.0
Reporter: Mike Q
Priority: Critical
I have the following object model
object TimeSeriesPeriod
has many-to-one to TimeSeriesQuality
has many-to-one to MeterPointTimeSeries
object TimeSeriesQuality
object MeterPointTimeSeries
has many-to-one to MeterPoint
object MeterPoint
Writing the following HQL generates incorrect SQL.
has many-to-one to TimeSeriesQuality
{noformat}
select
t.meterPointTimeSeries.meterPoint,
t.timeSeriesQuality
from TimeSeriesPeriod t
{noformat}
The SQL AST generated is as follows.
{noformat}
\-[SELECT] QueryNode: 'SELECT' querySpaces (MeterPoint,TimeSeriesQuality,MeterPointTimeSeries,TimeSeriesPeriod)
+-[SELECT_CLAUSE] SelectClause: '{select clause}'
| +-[DOT] DotNode: 'meterpoint2_.id as id222_0_' {propertyName=meterPoint,dereferenceType=EOF,propertyPath=meterPoint,path=t.meterPointTimeSeries.meterPoint,tableAlias=meterpoint2_,className=com.junifer.thor.database.hibernate.objects.MeterPoint,classAlias=null}
| | +-[DOT] DotNode: 'timeseries0_.meterPointTimeSeriesFk' {propertyName=meterPointTimeSeries,dereferenceType=EOF,propertyPath=meterPointTimeSeries,path=t.meterPointTimeSeries,tableAlias=meterpoint1_,className=com.junifer.thor.database.hibernate.objects.MeterPointTimeSeries,classAlias=null}
| | | +-[ALIAS_REF] IdentNode: 'timeseries0_.id' {alias=t, className=com.junifer.thor.database.hibernate.objects.TimeSeriesPeriod, tableAlias=timeseries0_}
| | | \-[IDENT] IdentNode: 'meterPointTimeSeries' {originalText=meterPointTimeSeries}
| | \-[IDENT] IdentNode: 'meterPoint' {originalText=meterPoint}
| +-[DOT] DotNode: 'timeseries3_.id as id438_1_' {propertyName=timeSeriesQuality,dereferenceType=EOF,propertyPath=timeSeriesQuality,path=t.timeSeriesQuality,tableAlias=timeseries3_,className=com.junifer.thor.database.hibernate.objects.TimeSeriesQuality,classAlias=null}
| | +-[ALIAS_REF] IdentNode: 'timeseries0_.id' {alias=t, className=com.junifer.thor.database.hibernate.objects.TimeSeriesPeriod, tableAlias=timeseries0_}
| | \-[IDENT] IdentNode: 'timeSeriesQuality' {originalText=timeSeriesQuality}
| +-[SQL_TOKEN] SqlFragment: 'meterpoint2_.assetFk as assetFk222_0_, meterpoint2_.deleteFl as deleteFl222_0_, meterpoint2_.measurand as measurand222_0_, meterpoint2_.meterTypeFk as meterTyp7_222_0_, meterpoint2_.partitionId as partitio4_222_0_, meterpoint2_.versionNo as versionNo222_0_'
| \-[SQL_TOKEN] SqlFragment: 'timeseries3_.code as code438_1_, timeseries3_.deleteFl as deleteFl438_1_, timeseries3_.iconTblFk as iconTblFk438_1_, timeseries3_.internalKey as internal4_438_1_, timeseries3_.languageKey as language5_438_1_, timeseries3_.orderNo as orderNo438_1_, timeseries3_.partitionId as partitio7_438_1_, timeseries3_.versionNo as versionNo438_1_'
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=4, fromElements=4, fromElementByClassAlias=[t], fromElementByTableAlias=[meterpoint1_, meterpoint2_, timeseries3_, timeseries0_], fromElementsByPath=[t.timeSeriesQuality, t.meterPointTimeSeries.meterPoint, t.meterPointTimeSeries], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'TimeSeriesPeriod timeseries0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=t,role=null,tableName=TimeSeriesPeriod,tableAlias=timeseries0_,origin=null,columns={,className=com.junifer.thor.database.hibernate.objects.TimeSeriesPeriod}}
| +-[FROM_FRAGMENT] ImpliedFromElement: 'MeterPointTimeSeries meterpoint1_' ImpliedFromElement{implied,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=MeterPointTimeSeries,tableAlias=meterpoint1_,origin=TimeSeriesPeriod timeseries0_,columns={timeseries0_.meterPointTimeSeriesFk ,className=com.junifer.thor.database.hibernate.objects.MeterPointTimeSeries}}
| | \-[JOIN_FRAGMENT] FromElement: 'inner join MeterPoint meterpoint2_ on meterpoint1_.meterPointFk=meterpoint2_.id' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=MeterPoint,tableAlias=meterpoint2_,origin=MeterPointTimeSeries meterpoint1_,columns={meterpoint1_.meterPointFk ,className=com.junifer.thor.database.hibernate.objects.MeterPoint}}
| \-[JOIN_FRAGMENT] FromElement: 'inner join TimeSeriesQuality timeseries3_ on timeseries0_.timeSeriesQualityFk=timeseries3_.id' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=TimeSeriesQuality,tableAlias=timeseries3_,origin=TimeSeriesPeriod timeseries0_,columns={timeseries0_.timeSeriesQualityFk ,className=com.junifer.thor.database.hibernate.objects.TimeSeriesQuality}}
\-[WHERE] SqlNode: 'WHERE'
\-[THETA_JOINS] SqlNode: '{theta joins}'
\-[SQL_TOKEN] SqlFragment: 'timeseries0_.meterPointTimeSeriesFk=meterpoint1_.id'
{noformat}
The SQL generated is as follows
{noformat}
select
meterpoint2_.id as id222_0_,
timeseries3_.id as id438_1_,
meterpoint2_.assetFk as assetFk222_0_,
meterpoint2_.deleteFl as deleteFl222_0_,
meterpoint2_.measurand as measurand222_0_,
meterpoint2_.meterTypeFk as meterTyp7_222_0_,
meterpoint2_.partitionId as partitio4_222_0_,
meterpoint2_.versionNo as versionNo222_0_,
timeseries3_.code as code438_1_,
timeseries3_.deleteFl as deleteFl438_1_,
timeseries3_.iconTblFk as iconTblFk438_1_,
timeseries3_.internalKey as internal4_438_1_,
timeseries3_.languageKey as language5_438_1_,
timeseries3_.orderNo as orderNo438_1_,
timeseries3_.partitionId as partitio7_438_1_,
timeseries3_.versionNo as versionNo438_1_
from
TimeSeriesPeriod timeseries0_,
MeterPointTimeSeries meterpoint1_
inner join MeterPoint meterpoint2_ on meterpoint1_.meterPointFk=meterpoint2_.id
inner join TimeSeriesQuality timeseries3_ on timeseries0_.timeSeriesQualityFk=timeseries3_.id
where timeseries0_.meterPointTimeSeriesFk=meterpoint1_.id
{noformat}
And the error produced is
{noformat}
The multi-part identifier "timeseries0_.timeSeriesQualityFk" could not be bound.
{noformat}
The SQL above is wrong because the second inner join should be appearing after the first from statement rather than the second one.
Looking at the AST fragment around the joins (some content removed for clarity
{noformat}
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=4, fromElements=4, fromElementByClassAlias=[t], fromElementByTableAlias=[meterpoint1_, meterpoint2_, timeseries3_, timeseries0_], fromElementsByPath=[t.timeSeriesQuality, t.meterPointTimeSeries.meterPoint, t.meterPointTimeSeries], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'TimeSeriesPeriod timeseries0_'
| +-[FROM_FRAGMENT] ImpliedFromElement: 'MeterPointTimeSeries meterpoint1_'
| | \-[JOIN_FRAGMENT] FromElement: 'inner join MeterPoint meterpoint2_ on meterpoint1_.meterPointFk=meterpoint2_.id'
| \-[JOIN_FRAGMENT] FromElement: 'inner join TimeSeriesQuality timeseries3_ on timeseries0_.timeSeriesQualityFk=timeseries3_.id'
{noformat}
Note the second join fragement appears last but is the child of the first from fragment. This looks to be correct. However when the SQL is rendered I'm guessing these nodes are rendered in their order as they appear here rather than rendering the second join fragment under the first from.
The tree does look a bit odd as one from fragment is the child of the other but there are unrelated, I would expect both to be children of the main FromClause with one join fragment child each.
Reversing the order of the select clause elements works correctly.
--
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, 11 months
[Hibernate-JIRA] Created: (JPA-10) JPA Criteria API Typesafety on equal
by Sebastian Braun (JIRA)
JPA Criteria API Typesafety on equal
------------------------------------
Key: JPA-10
URL: http://opensource.atlassian.com/projects/hibernate/browse/JPA-10
Project: Java Persistence API
Issue Type: Bug
Affects Versions: 1.0.0
Environment: Java 1.6.0_18
Hibernate 3.5.1-Final
Reporter: Sebastian Braun
Attachments: Example.zip
By Using the Typesafe JPA Criteria API i _dont_ get a Compile Error by compiling the code below:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("hibernatetest");
EntityManager em = emf.createEntityManager();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Employee> c = cb.createQuery(Employee.class);
Root<Employee> root = c.from(Employee.class)
// No Compile Error, but Exception on Runtime, because "name" is a String and the check parameter is an Integer
Predicate condition = cb.equal(root.get(Employee_.name), 1);
Obviously thats because the method in CriteriaBuilderImpl takes an Object as the second argument:
public Predicate equal(Expression<?> x, Object y) {...}
If this method would look like this the code above will show the correct Compile error
public <T> Predicate equal(Expression<T> x, T y) {...}
Corresponding Example Project is attached.
--
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, 11 months
[Hibernate-JIRA] Created: (HHH-3230) getEntityName() throws org.hibernate.TransientObjectException: proxy was not associated with the session
by Howard M. Lewis Ship (JIRA)
getEntityName() throws org.hibernate.TransientObjectException: proxy was not associated with the session
--------------------------------------------------------------------------------------------------------
Key: HHH-3230
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3230
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.2
Environment: Mac OS X, JDK 1.5
Reporter: Howard M. Lewis Ship
I'm retrieving an entity that contains a OneToMany relationship.
The master entity is retrieved, within a transaction, via Session.get(Class,Serializable).
@Entity
public class MapUnitSurvey extends ActiveDO
{
@ManyToOne(fetch = FetchType.LAZY)
private VegetationType vegetationType;
}
@Entity
public class VegetationType extends AbstractEnum
{
}
ActiveDO and AbstractEnum are abstract base classes with @MappedSuperclass.
I retrieve the vegationType:
VegetationType type = survey.getVegetationType();
Then I need the type's entity name
String entityName = session.getEntityName(type);
This fails with the TransientObjectException.
Inspecting with the debugger, I see that type is a CGLIB-enhanced proxy, and that there's a fully initialized bean in the target field of the proxy. I'll attach a screenshot of some debugging data.
In summary; the entity was retrieved via a lazy fetch, appears the be correct, seems to be in the session and yet the exception occurs.
I've tried to resolve this by re-fetching the object from the session, and a few other tries, with no luck.
--
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, 11 months
[Hibernate-JIRA] Updated: (HHH-1481) any mapping with composite id-type does not work
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1481?page=c... ]
Gail Badner updated HHH-1481:
-----------------------------
Affects Version/s: 3.6.0
> any mapping with composite id-type does not work
> ------------------------------------------------
>
> Key: HHH-1481
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1481
> Project: Hibernate Core
> Issue Type: Patch
> Affects Versions: 3.0 alpha, 3.0 beta 1, 3.0 beta 2, 3.0 beta 3, 3.0 beta 4, 3.0 rc 1, 3.0 final, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1 beta 1, 3.1 beta 2, 3.1 rc 1, 3.1 rc2, 3.1 rc3, 3.1, 3.1.1, 3.1.2, 3.2.0.alpha1, 3.1.3, 3.6.0
> Environment: Hibernate 3.1.2
> Reporter: Michael Matt
> Attachments: patch.zip
>
> Original Estimate: 10m
> Remaining Estimate: 10m
>
> Any mapping with composite id-type throws MappingException 'property mapping has wrong number of columns'.
> The zipped patch file contains:
> -bugfix for AnyType.java
> - testcases any mapping with simple id-type and composite id-type
--
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, 11 months
[Hibernate-JIRA] Commented: (HHH-1481) any mapping with composite id-type does not work
by Leandro Subils (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1481?page=c... ]
Leandro Subils commented on HHH-1481:
-------------------------------------
Yes, this bug is still in 3.6.0 version
> any mapping with composite id-type does not work
> ------------------------------------------------
>
> Key: HHH-1481
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1481
> Project: Hibernate Core
> Issue Type: Patch
> Affects Versions: 3.0 alpha, 3.0 beta 1, 3.0 beta 2, 3.0 beta 3, 3.0 beta 4, 3.0 rc 1, 3.0 final, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1 beta 1, 3.1 beta 2, 3.1 rc 1, 3.1 rc2, 3.1 rc3, 3.1, 3.1.1, 3.1.2, 3.2.0.alpha1, 3.1.3
> Environment: Hibernate 3.1.2
> Reporter: Michael Matt
> Attachments: patch.zip
>
> Original Estimate: 10m
> Remaining Estimate: 10m
>
> Any mapping with composite id-type throws MappingException 'property mapping has wrong number of columns'.
> The zipped patch file contains:
> -bugfix for AnyType.java
> - testcases any mapping with simple id-type and composite id-type
--
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, 11 months