[Hibernate-JIRA] Created: (HHH-2955) Unnecessary version updates in two cases.
by Sławomir Wojtasiak (JIRA)
Unnecessary version updates in two cases.
-----------------------------------------
Key: HHH-2955
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2955
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.5
Environment: JDK 5.0
Reporter: Sławomir Wojtasiak
Attachments: HibernateTest.zip
I found two situations where hibernate generates unnecessary version updates. Let's illustrate it with a simple example:
Session session = SessionFactory.getSession();
Transaction transaction = session.getTransaction();
transaction.begin();
Article a = new Article();
a.setName( "atricle" );
*********************************************
*** Quantity is the owner of the relation ***
*********************************************
Quantity q = new Quantity();
q.setName( "quantity" );
q.setArticle( a );
a.getQuantities().add( q );
session.persist( a );
session.flush();
***** Hibernate generates following SQLs *****
Hibernate: select nextval ('hibernate_sequence')
Hibernate: select nextval ('hibernate_sequence')
Hibernate: insert into Article (name, version, id) values (?, ?, ?)
Hibernate: insert into Quantity (article_id, name, version, id) values (?, ?, ?, ?)
**********************************************
a.getQuantities().clear();
session.flush();
*** Hibernate generates following SQLs ***
Hibernate: update Article set name=?, version=? where id=? and version=?
This update of version field is performed because collection of quantities is marked as dirty, but Article entity is not relation owner so nothing change in database after this clear. Should it works like this? It looks like a bug because database remain unchanged so version changing is unnecessary in my opinion.
******************************************
session.clear();
**** SECOND PROBLEM ***
Now I generate true copy of persisted objects.
Notice that I use HashSet instead of PersistSet which was set during persist operation. This operation is similar to merging objects prepared by SOAP, during communication with remote client for example.
***********************
Article a1 = new Article();
a1.setId( a.getId() );
a1.setName( a.getName() );
a1.setVersion( a.getVersion() );
Quantity q1 = new Quantity();
q1.setArticle( a1 );
q1.setName( q.getName() );
q1.setVersion( q.getVersion() );
q1.setId( q.getId() );
a1.getQuantities().add( q1 );
a1 = (Article)session.merge( a1 );
session.flush();
***** This operation generates following SQLs *****
Hibernate: select article0_.id as id0_1_, article0_.name as name0_1_, article0_.version as version0_1_, quantities1_.article_id as article4_3_, quantities1_.id as id3_, quantities1_.id as id1_0_, quantities1_.article_id as article4_1_0_, quantities1_.name as name1_0_, quantities1_.version as version1_0_ from Article article0_ left outer join Quantity quantities1_ on article0_.id=quantities1_.article_id where article0_.id=?
Hibernate: update Article set name=?, version=? where id=? and version=?
It looks like problem is located in replaceElements() method of CollectgionType class (or somewhere near it). Maybe I'm wrong but this collection was checked for changes during merge operation (See this select above.) so why it remains dirty if it contains the same data as database?. I checked this issue on other JPA implementations (OpenJPA for example) and version is not incremented after similar merge operation.
*****************************************************
transaction.rollback();
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-5580) tracking entity names in a revision
by Vardan Akopian (JIRA)
tracking entity names in a revision
-----------------------------------
Key: HHH-5580
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5580
Project: Hibernate Core
Issue Type: New Feature
Components: envers
Affects Versions: 3.5.5
Environment: hibernate 3.5.5
Reporter: Vardan Akopian
Attachments: envers-entity-names.patch
Currently Envers provides no way of finding which entities have been affected in a given revision. I.e. given a revision number it's impossible to find all the versions of all the entities for that revision. For example, all the search methods in the AuditQuery API take the entity class as a parameter. In our application we need to be able to retrieve all the changes for a given revision number without prior knowledge of which entities have been modified. Similar questions and requests have been posted in the envers forums before. The attached patch has a simple implementation for this feature. It adds 2 simple methods to the RevisionListener interface, that are called from AuditProcess and allow the Revision Entity to keep track of the entity names that are changed. The test cases show the simple usage for this.
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-5844) SQLServer 2008 and latest Microsoft JDBC jar causes exception
by guy bashan (JIRA)
SQLServer 2008 and latest Microsoft JDBC jar causes exception
-------------------------------------------------------------
Key: HHH-5844
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5844
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.0
Reporter: guy bashan
Attachments: sqljdbc4.jar
I am working with SQL Server 2008.
I just upgraded to the Microsoft latest JDBC driver: sqljdbc4.jar
I am getting this exception:
org.hibernate.MappingException: No Dialect mapping for JDBC type: -9
org.hibernate.dialect.TypeNames.get(TypeNames.java:78)
org.hibernate.dialect.TypeNames.get(TypeNames.java:103)
org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:328)
org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:590)
org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:516)
org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:532)
org.hibernate.loader.Loader.getResultSet(Loader.java:1962)
org.hibernate.loader.Loader.doQuery(Loader.java:802)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
org.hibernate.loader.Loader.doList(Loader.java:2533)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
org.hibernate.loader.Loader.list(Loader.java:2271)
org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
com.todacell.ui.model.dao.CampaignDAO.getNetworkCampaigns(CampaignDAO.java:86)
com.todacell.ui.view.bean.campaign.CampaignBrowseListBean$Model.getCampaigns(CampaignBrowseListBean.java:141)
com.todacell.ui.view.bean.campaign.CampaignBrowseListBean$Model.fetchPage(CampaignBrowseListBean.java:91)
com.anydoby.jsfpager.PagedListDataModel.fetchPageInternal(PagedListDataModel.java:152)
com.anydoby.jsfpager.PagedListDataModel.getPage(PagedListDataModel.java:100)
com.anydoby.jsfpager.PagedListDataModel.getWrappedData(PagedListDataModel.java:161)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:140)
org.apache.el.parser.AstValue.getValue(AstValue.java:118)
org.apache.el.parser.AstEmpty.getValue(AstEmpty.java:45)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
javax.faces.component._ComponentUtils.getExpressionValue(_ComponentUtils.java:236)
javax.faces.component.UIComponentBase.getExpressionValue(UIComponentBase.java:1176)
javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:1251)
org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:276)
org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
org.ajax4jsf.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:78)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:611)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:250)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
org.apache.myfaces.application.jsp.JspViewHandlerImpl.actuallyRenderView(JspViewHandlerImpl.java:427)
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:383)
org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:155)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:301)
com.todacell.ui.view.filter.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:105)
com.todacell.ui.view.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:61)
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-3051) NPE while query.list on a Native SQL, using L2 cache
by Amit Kapoor (JIRA)
NPE while query.list on a Native SQL, using L2 cache
----------------------------------------------------
Key: HHH-3051
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3051
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5ga
Database Oracle 9i
Jdk - 1.4.2_13
EHCache 1.2.3 / OsCache 2.1 both
Reporter: Amit Kapoor
I get an NPE when i try to execute a native query.
Below is the excerpt of the code that throws NPE:
String sqlQuery = "select emp_id, emp_first_name from employee_mt";
SQLQuery query = session.createSQLQuery(sqlQuery);
query.setCacheable(true).setCacheRegion("TEST_REGION");
query.addScalar("emp_id");
query.addScalar("emp_first_name");
List list = query.list();
query.list() throws the following NPE:
java.lang.NullPointerException
at org.hibernate.type.TypeFactory.disassemble(TypeFactory.java:451)
at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:83)
at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2194)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2138)
at org.hibernate.loader.Loader.list(Loader.java:2096)
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:152)
at poc.hibernate.caching.QueryCaching.fireNativeSql(QueryCaching.java:112)
at poc.hibernate.caching.QueryCaching.fireQuery(QueryCaching.java:38)
at poc.hibernate.caching.QueryCaching.main(QueryCaching.java:27)
I tried tracing through the Hibernate code code and saw that the types[] in the at the time of execution of types[i].disassemble( row[i], session, owner ) (TypeFactory.disassemble()) was holding both the types as null.
However before reaching that piece of code CustomLoader.autoDiscoverTypes(resultset) had already resolved the resultTypes to appropriate values.
Hope this helps.
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-6020) Move to JBossTS caused some test failures in hibernate-envers
by Steve Ebersole (JIRA)
Move to JBossTS caused some test failures in hibernate-envers
-------------------------------------------------------------
Key: HHH-6020
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6020
Project: Hibernate Core
Issue Type: Bug
Components: envers
Reporter: Steve Ebersole
Assignee: Adam Warski
Fix For: 4.0.0.Alpha2
Specifically there is 1 tests that fails in both configurations for a total of 2 failures. The test class is {{org.hibernate.envers.test.integration.jta.JtaTransaction}}. The failure says:
{noformat}
null
org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:110)
at org.hibernate.service.internal.ServiceInitializer.configureService(ServiceInitializer.java:141)
at org.hibernate.service.internal.ServiceInitializer.initializeService(ServiceInitializer.java:108)
at org.hibernate.service.internal.ServiceRegistryImpl.getServiceInternal(ServiceRegistryImpl.java:119)
at org.hibernate.service.internal.proxy.javassist.ServiceProxyFactoryImpl$ServiceProxyMethodInterceptor.invoke(ServiceProxyFactoryImpl.java:114)
at org.hibernate.engine.jdbc.spi.JdbcServices_$$_javassist_0.getExtractedMetaDataSupport(JdbcServices_$$_javassist_0.java)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:77)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2848)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2844)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1825)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:77)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:888)
at org.hibernate.envers.test.AbstractEntityTest.init(AbstractEntityTest.java:123)
at org.hibernate.envers.test.AbstractEntityTest.init(AbstractEntityTest.java:97)
...
{noformat}
JdbcServicesImpl.java:110 is a simple attempt to use the {{java.sql.Connection}} returned by the configured {{org.hibernate.service.jdbc.connections.spi.ConnectionProvider}}:
{code}
Connection conn = connectionProvider.getConnection();
try {
DatabaseMetaData meta = conn.getMetaData(); // <- this is line 110
...
{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, 4 months