[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
14 years, 10 months
[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
14 years, 10 months
[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
14 years, 10 months
[Hibernate-JIRA] Created: (HBX-1110) Support for abstract/concrete pairs of POJO generation for hbm2java
by Jeff Walker (JIRA)
Support for abstract/concrete pairs of POJO generation for hbm2java
-------------------------------------------------------------------
Key: HBX-1110
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1110
Project: Hibernate Tools
Issue Type: Patch
Components: ant, hbm2java, reverse-engineer
Affects Versions: 3.2.4 Beta1
Environment: Hibernate 3.3.1GA, DB2 8.2, ant 1.6.5, Java 5.0 b11, eclipse (myEclipse blue 7.0) on windows xp sp3
Reporter: Jeff Walker
Priority: Minor
Attachments: HibernateExt.patch
I wanted hbm2java to be able to produce pairs of both abstract base classes and concrete classes for each POJO when reverse engineering.
I altered the ant tasks to allow this syntax:
<hbm2java ejb3="true" jdk5="true">
<base transform="{package-name}/base/{class-name}Base"/>
<concrete transform="{package-name}/{class-name}"/>
</hbm2java>
I then extended the POJO exporter (used only when base or concrete are present). This new exporter takes the meta model and runs once for all components, and then twice for each entity. The first entity run is for the base classes. Using the meta property overrides in the exporter, I force the class to be abstract, and change the generated class name according to the "transform" attribute. I also save the name of the generated class name in a hash, mapped to the original name for use in the second phase.
Then for the second run (still inside of the exporter), I force the generated class name (again via the "transform" attribute), and have the class extend the base class that was generated in the first phase.
I also introduce two new variables into the template context: basePartOfPair and concretePartOfPair. Set to true or false for the respective phase. They default to false for when the regular exporter is used.
In the templates I forced the properties to be protected (instead of private), and turned off the property generation for the concrete class. I have code in the method (exportPersistentClass) to override these at meta properties, but that didn't work, as those properties need to be set on the property level, not the class level.
You may refer to the following forum post for more background: http://forum.hibernate.org/viewtopic.php?t=994243
Note that there is no test case for this functionality yet. I'm not sure where to put it or what to do with that, but I will keep looking at that.
--
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, 10 months
[Hibernate-JIRA] Created: (HHH-3945) Envers using inheritance gives NullPointer
by robbie123456 (JIRA)
Envers using inheritance gives NullPointer
------------------------------------------
Key: HHH-3945
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3945
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.5
Environment: 3.2.6.ga
Oracle 10g
Reporter: robbie123456
Using Envers version 3.5.0-SNAPSHOT:
class A extends from B. They both have @Entity and B has with @Inheritance(strategy=InheritanceType.JOINED), so fields in the subclass A have a separate table.
When only setting A to @Audited, I get following NullPointerException (found closed JIRA ticket: https://jira.jboss.org/jira/browse/ENVERS-71):
Caused by: java.lang.NullPointerException
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateInheritanceMappingData(AuditMetadataGenerator.java:253)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:301)
at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:87)
at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86)
at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:259)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:356)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1304)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
... 39 more
NullPointerException happens here because 'entitiesConfigurations' is empty:
String parentEntityName = pc.getSuperclass().getEntityName();
ExtendedPropertyMapper parentPropertyMapper = entitiesConfigurations.get(parentEntityName).getPropertyMapper();
When also putting @Audited to the superclass B, I get following exception (also found on Hibernate JIRA ticket: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3647):
org.hibernate.HibernateException: instance not of expected entity type: java.util.HashMap is not a: B_AUD
at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassEntityPersister(AbstractEntityPersister.java:3635)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1347)
at org.hibernate.id.Assigned.generate(Assigned.java:28)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:99)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.envers.synchronization.work.ModWorkUnit.perform(ModWorkUnit.java:60)
at org.hibernate.envers.synchronization.AuditSync.executeInSession(AuditSync.java:126)
at org.hibernate.envers.synchronization.AuditSync.beforeCompletion(AuditSync.java:150)
at org.hibernate.transaction.JDBCTransaction.notifyLocalSynchsBeforeTransactionCompletion(JDBCTransaction.java:228)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:109)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:709)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at net.x.prl.services.common.audit.UserAuditInterceptor.invoke(UserAuditInterceptor.java:32)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at net.x.prl.services.common.ServiceExceptionInterceptor.invoke(ServiceExceptionInterceptor.java:34)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy114.updateQuantityOnSalesForecastLine(Unknown Source)
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:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy114.updateQuantityOnSalesForecastLine(Unknown Source)
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:585)
at org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:205)
at org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:38)
at org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:78)
at net.x.buildit.middleware.jms.lingo.listener.EndpointExporterMessageListener.invokeAndCreateResult(EndpointExporterMessageListener.java:151)
at net.x.buildit.middleware.jms.lingo.listener.EndpointExporterMessageListener.doInvoke(EndpointExporterMessageListener.java:106)
at org.logicblaze.lingo.jms.JmsServiceExporterMessageListener.onMessage(JmsServiceExporterMessageListener.java:102)
at net.x.buildit.middleware.jms.lingo.listener.EndpointExporterMessageListener.onMessage(EndpointExporterMessageListener.java:220)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:531)
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:466)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:435)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:944)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:868)
at java.lang.Thread.run(Thread.java:595)
Using Envers with entity classes without inheriting from another entity, gives no 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, 10 months
[Hibernate-JIRA] Created: (HHH-2845) "Another ORA-00907: missing right parenthesis" bug with Oracle
by Dean Pullen (JIRA)
"Another ORA-00907: missing right parenthesis" bug with Oracle
--------------------------------------------------------------
Key: HHH-2845
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2845
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.5
Environment: hibernate-entitymanager.jar (3.3.1ga)
hibernate-annotations.jar (v 3.3.0ga)
hibernate-commons-annotations.jar (within Hibernate Annotations.rar\lib)
ejb3-persistence.jar (within Hibernate Annotations.rar\lib)
hibernate3.jar (v 3.2.5.ga)
Oracle 10g
Reporter: Dean Pullen
I'm using JBoss 4.2.1GA, with the Hibernate environment described above, using Oracle 10g, and attempting to perform a query.
I've been receiving a "ORA-00907: missing right parenthesis" error when attempting to perform the query.
Now a similar bug had this down to Hibernate using the 'as' keyword in the query, aliasing the table name - something that has been fixed in Hibernate 3.3.0ga.
(Aliasing a table in the SQL spec is optional, Oracle doesn't support it)
But I still get the same error. The query still contains the 'as' keyword (but not aliasing a table)
Here is an example:
I have two tables. CSIUsers and CSIUserSurveys.
There is a one-to-many mapping between CSIUsers to CSIUserSurveys.
Query query = entityManager.createQuery("FROM " + CSIUser.class.getSimpleName()
+ " cu LEFT JOIN cu.csiUserSurveys us"
+ " WHERE NOT EXISTS (SELECT us FROM cu.csiUserSurveys us WHERE us.csiUserId = cu.csiUserId)");
Result:
[[14 Sep 2007 15:43:52] DEBUG org.hibernate.util.JDBCExceptionReporter - could n
ot execute query [select csiuser0_.CSI_USER_ID as CSI1_15_0_, csiusersur1_.CSI_U
SER_ID as CSI1_16_1_, csiusersur1_.SURVEY_TYPE_CODE as SURVEY2_16_1_, csiuser0_.
COMPANY_CODE as COMPANY2_15_0_, csiuser0_.EMAIL_ADDRESS as EMAIL3_15_0_, csiuser
0_.FAILED_LOGINS as FAILED4_15_0_, csiuser0_.LOCALE as LOCALE15_0_, csiuser0_.PA
SSWORD as PASSWORD15_0_, csiuser0_.PURCHASE_DATE as PURCHASE7_15_0_, csiuser0_.S
TATUS as STATUS15_0_, csiuser0_.USER_NAME as USER9_15_0_, csiuser0_.USER_PRIVILE
GE as USER10_15_0_, csiusersur1_.SURVEY_INVITE_DATE as SURVEY3_16_1_ from CSI_US
ERS csiuser0_ left outer join CSI_USER_SURVEYS csiusersur1_ on csiuser0_.CSI_USE
R_ID=csiusersur1_.CSI_USER_ID where not (exists (select (csiusersur2_.CSI_USER_
ID, csiusersur2_.SURVEY_TYPE_CODE) from CSI_USER_SURVEYS csiusersur2_ where csiu
ser0_.CSI_USER_ID=csiusersur2_.CSI_USER_ID and csiusersur2_.CSI_USER_ID=csiuser0
_.CSI_USER_ID))]
java.sql.SQLException: ORA-00907: missing right parenthesis
--
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, 10 months