[Hibernate-JIRA] Created: (HHH-2288) Adding a new ResultTransformer, permitting to instantiate and fill related beans and not to take care of aliases case.
by Nicolas Billard (JIRA)
Adding a new ResultTransformer, permitting to instantiate and fill related beans and not to take care of aliases case.
----------------------------------------------------------------------------------------------------------------------
Key: HHH-2288
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2288
Project: Hibernate3
Type: Improvement
Components: query-sql, query-hql, query-criteria
Versions: 3.2.1
Environment: Developped based on hibernate v 3.2.1
Reporter: Nicolas Billard
Priority: Minor
Attachments: ResultTransformerImprovement.zip
Are joined to this post 2 classes. Below is the javadoc header of the ResultTransformer class.
May be this could be integrated in next hibernate versions ( certainly with improvements ... :p )
Let me know if anyone finds it useful ...
------------------------------------------------------
* Transforms resultset to value a bean, via setters.
*
* Examples:
*
* bean MyBean as 2 setters :
* - setId : takes an Integer
* - setProduct : takes a Product bean
*
* Product bean as 2 setters :
* - setId
* - setLib
*
* resultset may have these columns :
* - ID
* - PRODUCT_ID
* - PRODUCT_LIB
*
* A MyBean instance will be created for each tupple,
* and a Product instance will be also created, filled with PRODUCT_ID and PRODUCT_LIB values.
--
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
14 years, 11 months
[Hibernate-JIRA] Created: (HHH-2501) Read-only state of an entity in a session to propagate into subsequently lazy-loaded entities.
by Gunther Schadow (JIRA)
Read-only state of an entity in a session to propagate into subsequently lazy-loaded entities.
----------------------------------------------------------------------------------------------
Key: HHH-2501
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2501
Project: Hibernate3
Type: Improvement
Components: core
Environment: any
Reporter: Gunther Schadow
ISSUE:
Given an Entity entity and after Session.setReadOnly(entity), if the entity has lazy collections, lazy properties etc., other Entities are loaded into the Session upon navigating the object graph in the default read-writable state. However, it seems more reasonable to maintain the read-only state of the owning object.
REQUEST:
Ability to propagate read-only state of an entity in a session into other lazy-loaded entities.
BACKGROUND:
We have a system which permits users to make concurrent transactions which involve many of the same objects. Usually no changes happen on these shared objects, but instead connections (links) are made between these objects and new objects. For example, say you have an online meeting system, and every Meeting held has a link to a number of User object. The User objects are never changed in a Meeting, but there is a Relation called Participation (of User in Meeting) to which new relationships are added. When a new meeting is saved, it wants to save the User objects simply because a new Participation link entry was added to the collection.
To an extent we can prevent this from happening by setting the Users explicitly to read-only. However, now suppose we added a function "Invite your Friends" to a Meeting, in which we would simply go:
for(User friend : currentUser.getFriends())
meeting.addInvitation(friend);
Now an Invitation is like a Participation, and would be added into the User but now it wants to save these users just for a version upgrade only because they have received an Invitation.
--
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
14 years, 11 months
[Hibernate-JIRA] Created: (HHH-2094) Hibernate is ignoring native sql aliases and generating "column not found" error
by Leonardo Penczek (JIRA)
Hibernate is ignoring native sql aliases and generating "column not found" error
--------------------------------------------------------------------------------
Key: HHH-2094
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2094
Project: Hibernate3
Type: Bug
Components: query-sql
Versions: 3.2.0.cr4
Environment: 3.2.0.cr4, Adaptive Server Enterprise/12.5.3
Reporter: Leonardo Penczek
Priority: Critical
As simples as that:
1: Query q = em.createNativeQuery("select cd_person as codePerson, cd_person as identif from PERSON");
2: List<Object[]> resultList = (List<Object[]>) q.getResultList();
Hibernate is ignoring my aliases when retrieving information from the ResultSet because it is trying to retrieve by column name, generating the following error:
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:641)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)
at <my line 2 in the code above>
...
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2147)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:150)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)
...
Caused by: java.sql.SQLException: S0022: Invalid column name 'cd_person'.
at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError(Unknown Source)
at com.sybase.jdbc3.tds.TdsResultSet.findColumnByLabel(Unknown Source)
at com.sybase.jdbc3.jdbc.SybResultSet.findColumn(Unknown Source)
at com.sybase.jdbc3.jdbc.SybResultSet.getInt(Unknown Source)
at org.jboss.resource.adapter.jdbc.WrappedResultSet.getInt(WrappedResultSet.java:690)
at org.hibernate.type.IntegerType.get(IntegerType.java:28)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:139)
at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.extract(CustomLoader.java:474)
at org.hibernate.loader.custom.CustomLoader$ResultRowProcessor.buildResultRow(CustomLoader.java:420)
at org.hibernate.loader.custom.CustomLoader.getResultColumnOrRow(CustomLoader.java:317)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:594)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
Awesome! The SQL query runs, but the Hibernate try to get the column by the original name, not by the alias, causing the error!
It is not possible to correctly get the value of 2 different columns that have the same name!!!!
Hint: why Hibernate use ResultSet.get* by column name instead of positional ResultSet.get* (1, 2, 3,...)? It will solve this problem.
--
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
14 years, 11 months
[Hibernate-JIRA] Created: (HHH-2146) NullpointerException in DefaultDeleteEventListener.deleteTransientEntity
by Martin Kartumovich (JIRA)
NullpointerException in DefaultDeleteEventListener.deleteTransientEntity
------------------------------------------------------------------------
Key: HHH-2146
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2146
Project: Hibernate3
Type: Bug
Versions: 3.2.0.cr5
Environment: Hibernate 3.2.0cr5, Oracle10g
Reporter: Martin Kartumovich
Priority: Blocker
The following setup leads to a NPE in DefaultDeleteEventListener.deleteTransientEntity:
Tables A, B
Table V_A_B that is an M-N-Connection between A and B.
Pojo for A has a Set of V_A_Bs.
Pojo for B has a Set of V_A_Bs.
Pojo C that has Sets of As and Bs.
Cascades: all, delete-orphan
-Create a new A and add a new V_A_B to its Set, that references to an existing B.
-Delete B.
-SaveOrUpdate Pojo C.
In Hibernate 3.1.3 this works fine.
In 3.2.0cr4+cr5 the removal of B results into an cascading removal of the never persisted V_A_B in the Set of B instead of ignoring it.
This leads to an incorrect state where deleteTransientEntity is called with transientEnties=null.
When now calling transientEnties.contains(...) the NPE is thrown.
--
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
14 years, 11 months
[Hibernate-JIRA] Created: (HHH-2624) NullPointerException when Query.list()
by Eddie Man (JIRA)
NullPointerException when Query.list()
--------------------------------------
Key: HHH-2624
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2624
Project: Hibernate3
Issue Type: Bug
Components: core
Environment: MySQL database
Reporter: Eddie Man
Priority: Critical
Attachments: src.zip
The following exception was thrown when I calling Query.list():
Exception in thread "main" java.lang.NullPointerException
at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1641)
at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:608)
at org.hibernate.type.EntityType.resolve(EntityType.java:382)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2211)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
at org.hibernate.loader.Loader.list(Loader.java:2090)
Reference issue :
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-48
Steps for reproduce the problem
==================
1. Unzip the attached file.
2. Execute the "schema.ddl" to create the tables.
3. Execute the "data.ddl" to insert the simple records.
4. Compile the src, and run the Main class.
--
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
14 years, 11 months
[Hibernate-JIRA] Created: (HHH-2399) FlushMode.AUTO practically unusable - should not flush before EVERY query
by Piotr Kołaczkowski (JIRA)
FlushMode.AUTO practically unusable - should not flush before EVERY query
-------------------------------------------------------------------------
Key: HHH-2399
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2399
Project: Hibernate3
Type: Improvement
Versions: 3.1.3, 3.2.1, 3.2.2, 3.2.0.ga
Environment: PostgreSQL 8.1.5, JDBC 2 and 3, Linux kernel 2.4.x, 2.6.x, Java 1.5.0_09
Reporter: Piotr Kołaczkowski
Attachments: hbtest.zip
The method flushIfRequired seems to flush before every query execution, even though there wasn't anything changed to the objects in the session, and the objects in the session are of different class than the object(s) queried. When having more than a few such objects in a session, it may lead to large, unneeded overheads (I noticed 10-200 times slowdown on simple queries). Our system uses many fast queries, that uasually return only one result or few results. The average query durations on different levels, measured by System.nanoTime() (see the attachment):
- database level: 0.05 ms
- pure JDBC code, prepared statements: 0.2 ms
- pure JDBC code, no prepared statements: 0.7 ms
- not cached hibernate query, no other objects associated with the session: 1.3 ms
- cached hibernate query, object in the session cache, no other objects associated with the session: 1.1 ms
- cached hibernate query, 10000 very simple objects of some other class in the session: >50 ms
10000 may seem large, but note these were very simple objects, having only 2 properties. On our production system we have classes with many properties, and even 20 objects in a session can cause a sub-millisecond query to run longer than 5 ms. We switched to FlushMode.COMMIT, and now the performance is much better.
Can you do something about this? As far as I've read in JIRA, a similar issue exists in Hibernate 2.x, and is still OPEN / UNRESOLVED.
BTW. Why is the 1st level cache so slow in my tests? Why reading just a 2 field object from the database cause so much overhead over pure JDBC? What am I doing wrong?
There is so much marketing about using cglib reflection optimizer in the performance FAQ but even if I retrieved these objects using JDBC and reflection, I would achieve much better performance. After all 1 ms is very much time, if getting results from DB and sending them to JVM lasts 0.2 ms.
--
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
15 years
[Hibernate-JIRA] Created: (HHH-2347) Improvement to DerbyDialect default identy generation mode
by Fabrizio Giustina (JIRA)
Improvement to DerbyDialect default identy generation mode
----------------------------------------------------------
Key: HHH-2347
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2347
Project: Hibernate3
Type: Patch
Versions: 3.2.1
Reporter: Fabrizio Giustina
Attachments: DerbyDialect-identity.diff
although derby supports identities org.hibernate.dialect.DerbyDialect strangely uses an HiLo generation strategy for ids (for any other dialects that support identities IdentityGenerator is the default).
Even more curiously, DerbyDialect overrides getIdentityColumnString() from the Db2 dialect by using "generated ALWAYS as identity" instead of "generated BY DEFAULT as identity". Derby however fully supports "by default" in identities as clarified in http://db.apache.org/derby/docs/10.1/ref/rrefsqlj37836.html .
"by default" should be preferred since it allows a direct insertion when needed (and I can't see no reason why enabling it for db2 and not for derby).
The patch attached simply deletes two methods, so that the default implementation from Db2Dialect is used:
- removing getIdentityColumnString() make derby use "by default" identities like db2 already does
- removing getNativeIdentifierGeneratorClass() make it choose IdentityGenerator.class (it falls back to the default strategy used in org.hibernate.dialect.Dialect)
note that part of this issue has already been reported in HHH-1918 (not addressing the identity generation string)
--
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
15 years
[Hibernate-JIRA] Created: (HHH-2413) Offer a way to log bound jdbc parameters in a uniform way for UserType implementors
by Baptiste MATHUS (JIRA)
Offer a way to log bound jdbc parameters in a uniform way for UserType implementors
-----------------------------------------------------------------------------------
Key: HHH-2413
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2413
Project: Hibernate3
Type: Improvement
Versions: 3.2.2
Reporter: Baptiste MATHUS
Priority: Minor
At the moment, when someone implements a UserType, the bound parameters won't be displayed in not explicitly displayed via loggers.
For example, here is what the code of NullableType.nullSafeGet() is :
public final void nullSafeSet(PreparedStatement st, Object value, int index)
throws HibernateException, SQLException {
try {
if ( value == null ) {
if ( IS_TRACE_ENABLED ) {
log().trace( "binding null to parameter: " + index );
}
st.setNull( index, sqlType() );
}
else {
if ( IS_TRACE_ENABLED ) {
log().trace( "binding '" + toString( value ) + "' to parameter: " + index );
}
set( st, value, index );
}
}
catch ( RuntimeException re ) {
log().info( "could not bind value '" + toString( value ) + "' to parameter: " + index + "; " + re.getMessage() );
throw re;
}
catch ( SQLException se ) {
log().info( "could not bind value '" + toString( value ) + "' to parameter: " + index + "; " + se.getMessage() );
throw se;
}
}
IMO, it would be quite a good thing to provide some method in Hibernate, something like logBoundParameter() that would do the log like above :
> log().trace( "binding '" + toString( value ) + "' to parameter: " + index );
This method could then be just called by implementors so as to guaranty the display is always the same about bound parameters.
Even more, I think it should use a special logger, just like the org.hibernate.SQL one to display this parameters. In fact, at the moment, I feel the reference documentation is not very clear about this : see http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configurat.... It says :
> org.hibernate.type Log all JDBC parameters
But that's not completely true: it will only log bound parameters that are parameters typed with standard types coming from the org.hibernate.type package. Any custom UserType won't display anything until you:
1) put the right log4j line for the package where your userType is located ;
2) think about explicitly logging those parameter values in your custom UserType (cf. my first point).
I'm not sure I made myself totally clear,. If so, please let me know.
If you think that would be worth an improvement, I'll give a look to provide a patch for this. Thanks a lot.
--
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
15 years