[Hibernate-JIRA] Commented: (HHH-1813) 2nd level cached collections are locked causing a cache miss
by Erik Heckert (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1813?page=c... ]
Erik Heckert commented on HHH-1813:
-----------------------------------
Have a look at the internal class "Lock", method "isGettable(...)".
In my opinion it should read "freshTimestamp > txTimestamp",
not "... < ...".
Greets,
Erik
> 2nd level cached collections are locked causing a cache miss
> ------------------------------------------------------------
>
> Key: HHH-1813
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1813
> Project: Hibernate3
> Type: Bug
> Versions: 3.1
> Environment: Hibernate 3.1, Oracle 10g, Linux
> Reporter: Assaf Berg
> Priority: Critical
> Attachments: testcase.tar.gz
>
>
> Using the second level cache, collections are fetched from the database due to the cached item being locked.
> This happens in the most simple use case:
> 1. Insert an entity with a collection
> 2. Commit.
> 3. Fetch the entity
> I've written a simple test case and see the following in the log file:
> 11:52:47,159 DEBUG [ReadWriteCache] Invalidating: domain.Cat.kittens#539957
> 11:52:47,177 DEBUG [ReadWriteCache] Inserting: domain.Cat#539957
> 11:52:47,179 DEBUG [ReadWriteCache] Inserted: domain.Cat#539957
> 11:52:47,180 DEBUG [ReadWriteCache] Inserting: domain.Kitten#540214
> 11:52:47,180 DEBUG [ReadWriteCache] Inserted: domain.Kitten#540214
> 11:52:47,181 DEBUG [ReadWriteCache] Releasing: domain.Cat.kittens#539957
> 11:52:49,221 DEBUG [ReadWriteCache] Caching: domain.Cat#539957
> 11:52:49,221 DEBUG [ReadWriteCache] Item was already cached: domain.Cat#539957
> 11:52:49,223 DEBUG [ReadWriteCache] Cache lookup: domain.Cat.kittens#539957
> 11:52:49,223 DEBUG [ReadWriteCache] Cached item was locked: domain.Cat.kittens#539957
> 11:52:49,229 DEBUG [ReadWriteCache] Caching: domain.Kitten#540214
> 11:52:49,229 DEBUG [ReadWriteCache] Item was already cached: domain.Kitten#540214
> 11:52:49,230 DEBUG [ReadWriteCache] Caching: domain.Cat.kittens#539957
> 11:52:49,231 DEBUG [ReadWriteCache] Cached: domain.Cat.kittens#539957
> domain.Cat.kittens [C/H/M/P]: 1/0/1/1
> domain.Cat [C/H/M/P]: 1/0/0/1
> domain.Kitten [C/H/M/P]: 1/0/0/1
> This happens whether the collection is mapped as inverse or not.
> I've attached the test case source and hbms (although it might need to be tweaked for the proper DB before running, and I didn't include the dependencies JARs).
> Here's a code excerpt of the interesting part (tx is TransactionTemplate using HibnerateTransactionManager and hibernate is HibernateTemplate from the spring framework):
> tx.execute(new TransactionCallback() {
> public Object doInTransaction(TransactionStatus status) {
> // create a Cat with one Kitten
> Cat cat = new Cat();
> Kitten kitten = new Kitten();
> cat.addKitten(kitten);
>
> hibernate.save(cat);
>
> return null;
> }
> });
>
> Thread.sleep(2000L);
>
> tx.execute(new TransactionCallback() {
> public Object doInTransaction(TransactionStatus status) {
> // load all cats
> List<Cat> allCats = hibernate.loadAll(Cat.class);
> return null;
> }
> });
> I can supply further information if needed.
--
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
18 years, 5 months
[Hibernate-JIRA] Commented: (HHH-1258) startup time improvements
by Tyler Van Gorder (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1258?page=c... ]
Tyler Van Gorder commented on HHH-1258:
---------------------------------------
Hi Max, thanks for you work in this area, as it has been a long standing problem for us.
I recently posted to the news group about loading the configuration "on-demand" and in fact someone has created a patch to the 2.x code base to do just that. Is there any way this functionality could be included in the 3.x code base as well? I attempted to hack this project to move it to 3.2 but I am just not familar enough with the hibernate code. Here is my attached post from the forum to give you a better background on our startup time "woes". 8-)
We have 355 persistent classes (using a class per table approach on a legacy database schema). No, we can't change the schema unfortunately.
Some of the tables are large (150+ columns) with upwards of 30 FKs.
The startup time (To create and initialize the factory) is 20 Seconds on a P4 2.8Ghz machine. Some of the other machines in our development group take substantially longer (1 minute).
So for some really silly cost-benefit analysis:
6 developers X 30 seconds (on average) X 20 Unit test runs a day = 1 hour a day
1 hour * $29.00 == $29.00 a day.
29 * 52 weeks * 5 days == $7540 a year waiting for startup.
Yeah...I know really silly and probably a bit high.
=============================================================
We have been able to reduce our startup time by roughly half by (yeah! its now ~3K per year. 8-)
1) Moving all mapping to a singe XML file. Surprisingly, this improved startup by 25%.
2) Moving to the latest 3.2 release (Another 25%) Thanks!
We would really see great benefit from dynamically loading the configuration (as it is needed). This is strictly a developement time optimization to help speed the unit testing.
We have played with serializing the XML configuration and it gives us no benefit in startup times.
We found this plugin which does exactly what we want but it is for the 2.x release of hibernate. (Thanks Peter!)
http://sourceforge.net/projects/hbn-dyn-mod/
Is there any way that we could:
a) Have someone that is familar with the hibernate source to contribute a 3.x version of this module. (I am willing to contribute my attempt at this) and normally I would do this myself, but I have tight deadlines.
b) Possibly have this code integrated with the hibernate distribution as an "option"
Thanks.
Tyler Van Gorder
tkv(a)landacorp.com
> startup time improvements
> -------------------------
>
> Key: HHH-1258
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1258
> Project: Hibernate3
> Type: Improvement
> Components: core
> Versions: 3.1 rc3
> Reporter: Max Rydahl Andersen
> Assignee: Max Rydahl Andersen
>
>
> while doing some basic startup perf testing the following were found - this issue is mainly to track what I find, and then fix it:
> Initial tests where 100 classes, 30 sec for buildSessionFactory
> setting hibernate.cglib.use_reflection_optimizer false and it is 10 sec for buildSessionFactory.
> (maybe we should autodetect which jdk we are running on and disable it per default for 1.4/1.5 - needs to validate runtime impact)
> Another (22%) time stealer is the discovery of getter/setters - in worst case it iterates over all declared methods per property.
> (alternatively we could cache/sort this list or make a more efficient implementation if a class only contain default property accessors)
> Other 20% of the time is done in net.sf.cglib related classes for build time enhancement.
> The rest of the time is Configuration creation (can be cached) and other iteration code.
> (p.s. don't take the % numbers as hard values - these are definitly affected by how many methods/classes you have; this underlying tests
> is done on pojos with a "high" method count (approx 100)
--
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
18 years, 5 months
[Hibernate-JIRA] Created: (HHH-2120) composite-id in a parent-child mapping build a wrong query
by German de la Cruz (JIRA)
composite-id in a parent-child mapping build a wrong query
----------------------------------------------------------
Key: HHH-2120
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2120
Project: Hibernate3
Type: Bug
Components: query-hql
Versions: 3.0.5, 3.1.3
Environment: hibernate 3.0.5 or hibernate 3.1.3 as in the distribution tar.gz. . Y probe it in Oracle 9 and MySQL with the same result.
Reporter: German de la Cruz
Priority: Blocker
Attachments: CompositeIdTest.java
When I run the attached code (You can see it is the same class in tests in distribution file, but with a new method called testQuery2 that can reproduce the bug) Hibernate generate the following query.
Since I've probed it in two differents db's, I can't say it's a Dialect problem.
I can't reproduce it in hibernate-3.2.CR4 (It works fine). Then what I need is a backport to 3.0.5 and 3.1.3
HQL:
from LineItem ol where ol.order=:order
Generated SQL:
select
lineitem0_.customerId as customerId2_,
lineitem0_.orderNumber as orderNum2_2_,
lineitem0_.productId as productId2_,
lineitem0_.quantity as quantity2_
from
LineItem lineitem0_
where
(
lineitem0_.customerId, lineitem0_.orderNumber
)=?
--
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
18 years, 5 months
RE: Query.list() returns one item (as expected) but that item is null (which is unexpected)
by Mehdi.Rakhshani@gxs.com
By removing the composite key and making the dataId field be the key the
problem was resolved (both query and criteria work). I like to
understand what was the cause of the problem though. I am new to
hibernate, anyone knows enough about hibernate to comment on it?
________________________________
From: Rakhshani, Mehdi (GXS)
Sent: Tuesday, September 26, 2006 1:12 PM
To: 'hibernate-issues(a)lists.jboss.org'
Subject: RE: Query.list() returns one item (as expected) but that item
is null (which is unexpected)
I have a simple query that when I execute in sqlplus returns one record
as expected. When I run the same query using hibernate and java, I get a
list back which has one record, but that record is null.
I wrote the same search using Criteria and hibernate complains that the
column name cannot be resolved. Whether I use the "name" attribute or
the "column" attribute of the property it makes no difference.
Hibernate 3.1: 1,971,632 hibernate3.jar, Windows XP, Oracle DB
HBM snippet:
<hibernate-mapping package="com.gxs.iefe.alias">
<class
name="AliasTable"
table="IEFE.ALIAS_TABLE"
>
<meta attribute="sync-DAO">false</meta>
<composite-id name="id" class="AliasTablePK">
<key-property
name="owningSystem"
column="OWNING_SYSTEM"
type="string"
/>
<key-property
...
Code snippet using query:
q = theSession.createQuery(
"from AliasTable where OWNING_SYSTEM = :sys and
OWNING_ACCOUNT is null and OWNING_USER_ID is null and TABLE_NAME = :tbl"
);
q.setString( "sys", theOwner.getSystem() );
q.setString( "tbl", theTable );
// Using q.uniqueResult() produces the same behavior
List anAliasTableList = q.list();
if ( null == anAliasTableList || 0 ==
anAliasTableList.size() )
throw new Exception( "Null list" );
// Code that verifies list size has been removed. "Null list
element" is thrown.
anAliasTable = (AliasTable)anAliasTableList.get( 0 );
if ( null == anAliasTable )
throw new Exception( "Null list element" );
Code snippet using criteria:
Criteria aCriteria = theSession.createCriteria(
AliasTable.class );
// Specifying neither property name nor property
column works: could not resolve property: owningSystem of:
com.gxs.iefe.alias.AliasTable
//aCriteria.add( Restrictions.eq( "OWNING_SYSTEM",
theOwner.getSystem() ) );
aCriteria.add( Restrictions.eq( "owningSystem",
theOwner.getSystem() ) );
aCriteria.add( Restrictions.isNull( "owningAccount" ) );
aCriteria.add( Restrictions.isNull( "owningUserId" ) );
aCriteria.add( Restrictions.eq( "tableName", theTable ) );
// Retrieve the data
List anAliasTableList = aCriteria.list();
Any idea why?
18 years, 5 months
[Hibernate-JIRA] Created: (HHH-2117) hbm2ddl generate additional foreign key column for super class when try to map from holder class to sub class
by Egor (JIRA)
hbm2ddl generate additional foreign key column for super class when try to map from holder class to sub class
-------------------------------------------------------------------------------------------------------------
Key: HHH-2117
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2117
Project: Hibernate3
Type: Bug
Versions: 3.1.3
Environment: MS SQL 2000, PointBase Micro 5
Reporter: Egor
Priority: Minor
I have next classes
SuperClass
|
| * 1
SubClasss-----HolderClass
Mappings for this classes
<class name="SuperClass" table="locations" discriminator-value="0">
<id name="idSuperClass" type="short">
<column name="id_super_class" />
<generator class="assigned" />
</id>
<discriminator type="byte">
<column name="class_type" />
</discriminator>
......................................
</class>
<subclass name="SubClass" extends="SuperClass" discriminator-value="1">
<join table="SubClass">
<key>
<column name="id_super_class" />
</key>
<many-to-one name="holderClass" class="HolderClass" >
<column name="id_holder_class" />
</many-to-one>
......................................
</join>
</subclass>
<class name="HolderClass" table="HolderClass">
<id name="idHolderClass" type="short">
<column name="id_holder_class" />
<generator class="assigned" />
</id>
<bag name="subClassList" table="SubClass" inverse="true">
<key column="id_holder_class" />
<one-to-many class="SubClass" />
</bag>
......................................
</class>
When I try to generate schema with SchemaExport, i get next tables
FK
SuperClass-----
|PK |
|FK PK|
SubClasss-----HolderClass
FK
--
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
18 years, 5 months