[Hibernate-JIRA] Created: (HHH-3199) Some query fail in BinaryLogicOperatorNode.mutateRowValueConstructorSyntaxesIfNecessary when there is a one-to-one bidi relation.
by Benjamin Lerman (JIRA)
Some query fail in BinaryLogicOperatorNode.mutateRowValueConstructorSyntaxesIfNecessary when there is a one-to-one bidi relation.
---------------------------------------------------------------------------------------------------------------------------------
Key: HHH-3199
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3199
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6
Environment: Hibernate version 3.2.6.ga. Database postgreSQL,
Reporter: Benjamin Lerman
Attachments: example.zip
When mapping a one-to-one bidi relation with the following mappings :
<hibernate-mapping>
<class lazy="true" name="com.genia.toolbox.model.association.one_to_one_bidi.impl.DriverOneToOneBidiImpl" proxy="com.genia.toolbox.model.association.one_to_one_bidi.DriverOneToOneBidi" table="_driver_one_to_one_bidi">
<id name="identifier" column="_identifier" type="java.lang.Long" unsaved-value="null">
<generator class="hilo"><param name="table">_hibernate_unique_key_169</param></generator>
</id>
<one-to-one cascade="persist,merge,save-update" class="com.genia.toolbox.model.association.one_to_one_bidi.impl.CarOneToOneBidiImpl" name="carInternal" property-ref="driverInternal"/>
</class>
</hibernate-mapping>
and
<hibernate-mapping>
<class lazy="true" name="com.genia.toolbox.model.association.one_to_one_bidi.impl.CarOneToOneBidiImpl" proxy="com.genia.toolbox.model.association.one_to_one_bidi.CarOneToOneBidi" table="_car_one_to_one_bidi">
<id name="identifier" column="_identifier" type="java.lang.Long" unsaved-value="null">
<generator class="hilo"><param name="table">_hibernate_unique_key_181</param></generator>
</id>
<many-to-one cascade="persist,merge,save-update" class="com.genia.toolbox.model.association.one_to_one_bidi.impl.DriverOneToOneBidiImpl" name="driverInternal" column="_driver" unique="true"/>
</class>
</hibernate-mapping>
the following query:
FROM com.genia.toolbox.model.association.one_to_one_bidi.DriverOneToOneBidi AS a2, com.genia.toolbox.model.association.one_to_one_bidi.CarOneToOneBidi AS a3 WHERE ((a2.carInternal)=(a3))
failed with an exception:
left and right hand sides of a binary logic operator were incompatibile
This is due to the call to the method mutateRowValueConstructorSyntaxesIfNecessary of BinaryLogicOperatorNode.
One of the type is a OneToOneType which returns 0 for getColumnSpan while the other is a ManyToOneType that returns 1. The two values are not equal and an exception is thrown.
I join to this issue the relevant classes and mappings.
--
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
17 years, 7 months
[Hibernate-JIRA] Created: (HHH-3152) StaleStateException using many-to-many together with one-to-many
by Donatas Ciuksys (JIRA)
StaleStateException using many-to-many together with one-to-many
----------------------------------------------------------------
Key: HHH-3152
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3152
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: Hibernate EntityManager 3.3.1 GA, Hibernate Annotations 3.3.0 GA, Hibernate Core 3.2.6 GA.
DB2 9.5 (production), Derby 10.3.2.1 (reproducible test case)
Reporter: Donatas Ciuksys
Attachments: db_schema.gif, ManyToMany.zip
I have many-to-many association between tables A and B (via join table A_B, see attached db_schema.gif). Join table has additional data columns, so I represent it as entity AB and have two one-to-many associations (A <-> AB and B <-> AB, with cascade=Cascade.REMOVE). Also I have many-to-many association between A and B (joinColumns are marked with insertable=false, updatable=false, though the marking/unmarking doesn't change the behaviour).
Table A is modeled as abstract entity A that is inherited by two concrete entities ATrue and AFalse. Table A has column BOOL_PROP (boolean property) of type INTEGER. ATrue spans objects with BOOL_PROP being true (1), AFalse - being false (0), column BOOL_PROP is used as Discriminator column.
The problem: having in database several ATrue and AFalse entities, it is impossible to delete ATrue entity - StaleStateException is being thrown:
Code fragment (p.getAllTrueA() return list of ATrue entities):
em.getTransaction().begin();
em.remove(p.getAllTrueA().get(0));
em.getTransaction().commit();
Log and exception stack trace:
Hibernate: delete from A_B where A=?
2008-03-03 18:02:10,313 [main] DEBUG org.hibernate.type.IntegerType - binding '4' to parameter: 1
Hibernate: delete from ADMIN.A_B where ID=?
2008-03-03 18:02:10,403 [main] DEBUG org.hibernate.type.IntegerType - binding '4' to parameter: 1
2008-03-03 18:02:10,473 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
...
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
at manytomany.Main.run(Main.java:30)
at manytomany.Main.main(Main.java:15)
Exception in thread "main" javax.persistence.RollbackException: Error while commiting the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:71)
at manytomany.Main.run(Main.java:30)
at manytomany.Main.main(Main.java:15)
Caused by: javax.persistence.OptimisticLockException: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:654)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:59)
... 2 more
Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
...
The problem is that after:
Hibernate: delete from A_B where A=?
following statement is being executed:
Hibernate: delete from ADMIN.A_B where ID=?
The first statement deletes child A_B rows belonging to parent A. The second tries to delete what is already deleted.
Why I think it is related to many-to-many association: if I comment many-to-many association fields and getters/setters, problem is gone.
Attached is Eclipse project (standard java application), Derby DDL scripts. Following steps are needed to reproduce the problem:
1. Adjust the classpath (specify correct path to Hibernate EntityManager and its dependencies, Derby 10.3 derbyclient.jar)
2. Adjust database URL in /src/META-INF/persistence.xml (I'm using absolute path to DB, that is located at the projects root)
3. Start Derby network server (or adjust database URL to use embedded driver)
4. Start the application - it tries to delete ATrue entity and fails.
You can recreated the database if you wish - projects root folder contains DB_DDL.sql scripts. The program checks, whether the DB is empty, and if so, first fills it up with test data, then exits. Restart it again - it will load some ATrue entities and will try to delete one.
--
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
17 years, 8 months
[Hibernate-JIRA] Created: (HHH-3364) Missing table name + alias in FROM clause of generated SQL
by Istvan Kovacs (JIRA)
Missing table name + alias in FROM clause of generated SQL
----------------------------------------------------------
Key: HHH-3364
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3364
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.3.0.CR1, 3.2.6
Environment: hsqldb
Reporter: Istvan Kovacs
Same sources as HHH-3362 and HHH-3363
select emp.name
from
Employee emp, Product p
where
emp.shop.stock[p] > 5
and
p.name='Product_10'
SQL (missing the table SHOP, aliased as shop_2)
select
employee0_.name as col_0_0_
from
Employee employee0_,
PRODUCT product1_,
SHOP_PRODUCT_STOCK stock3_
where
employee0_.SHOP_ID=shop2_.SHOP_ID
and shop2_.SHOP_ID=stock3_.SHOP_ID
and stock3_.PRODUCT_ID = product1_.PRODUCT_ID
and stock3_.AMOUNT>5
and product1_.name='Product_10'
Stack trace is from 3.3.0.CR1, but problem is also present in 3.2.6
java.sql.SQLException: Column not found: SHOP2_.SHOP_ID in statement [select employee0_.name as col_0_0_ from Employee employee0_, PRODUCT product1_, SHOP_PRODUCT_STOCK stock3_ where employee0_.SHOP_ID=shop2_.SHOP_ID and shop2_.SHOP_ID=stock3_.SHOP_ID and stock3_.PRODUCT_ID = product1_.PRODUCT_ID and stock3_.AMOUNT>5 and product1_.name='Product_10']
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.console.HQLQueryPage.getList(HQLQueryPage.java:50)
at org.hibernate.eclipse.console.views.QueryPageViewer$ContentProviderImpl.getElements(QueryPageViewer.java:114)
at org.eclipse.jface.viewers.StructuredViewer.getRawChildren(StructuredViewer.java:937)
at org.eclipse.jface.viewers.ColumnViewer.getRawChildren(ColumnViewer.java:693)
at org.eclipse.jface.viewers.AbstractTableViewer.getRawChildren(AbstractTableViewer.java:1071)
at org.eclipse.jface.viewers.StructuredViewer.getFilteredChildren(StructuredViewer.java:871)
at org.eclipse.jface.viewers.StructuredViewer.getSortedChildren(StructuredViewer.java:994)
at org.eclipse.jface.viewers.AbstractTableViewer.internalRefreshAll(AbstractTableViewer.java:685)
at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:633)
at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:620)
at org.eclipse.jface.viewers.AbstractTableViewer$2.run(AbstractTableViewer.java:576)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1368)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1330)
at org.eclipse.jface.viewers.AbstractTableViewer.inputChanged(AbstractTableViewer.java:574)
at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:251)
at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1606)
at org.hibernate.eclipse.console.views.QueryPageViewer.createTable(QueryPageViewer.java:218)
at org.hibernate.eclipse.console.views.QueryPageViewer.createControl(QueryPageViewer.java:197)
at org.hibernate.eclipse.console.views.QueryPageViewer.<init>(QueryPageViewer.java:154)
at org.hibernate.eclipse.console.views.QueryPageTabView.rebuild(QueryPageTabView.java:114)
at org.hibernate.eclipse.console.views.QueryPageTabView$1.contentsChanged(QueryPageTabView.java:78)
at org.hibernate.eclipse.console.views.QueryPageTabView$1.intervalAdded(QueryPageTabView.java:88)
at javax.swing.AbstractListModel.fireIntervalAdded(Unknown Source)
at org.hibernate.console.QueryPageModel.add(QueryPageModel.java:67)
at org.hibernate.console.KnownConfigurations$1.queryPageCreated(KnownConfigurations.java:90)
at org.hibernate.console.ConsoleConfiguration.fireQueryPageCreated(ConsoleConfiguration.java:419)
at org.hibernate.console.ConsoleConfiguration.access$5(ConsoleConfiguration.java:415)
at org.hibernate.console.ConsoleConfiguration$4.execute(ConsoleConfiguration.java:391)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:383)
at org.hibernate.eclipse.hqleditor.HQLEditor.executeQuery(HQLEditor.java:406)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.execute(ExecuteQueryAction.java:72)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.run(ExecuteQueryAction.java:52)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.runWithEvent(ExecuteQueryAction.java:56)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:546)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:443)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
--
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
17 years, 8 months
[Hibernate-JIRA] Created: (ANN-749) Generated Annotation can not generate Date automatically
by yuanqingfei (JIRA)
Generated Annotation can not generate Date automatically
--------------------------------------------------------
Key: ANN-749
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-749
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.4.0.CR1, 3.3.1.GA
Environment: OS: Windows XP
DB: HSQL
Reporter: yuanqingfei
@Before
public void setup() {
order = new Order();
// enter all required fields
order.setName("order1");
order = orderDAO.save(order); //Hibernate should generate a timestamp here
}
@Test
public void testSave() {
assertTrue(orderDAO.exists(order.getId()));
System.out.println(order.getCreateTime()); //here should get a date.
}
Annotation part in Order:
@Temporal(TemporalType.TIMESTAMP)
@Column(insertable = false,updatable=false)
@org.hibernate.annotations.Generated(org.hibernate.annotations.GenerationTime.INSERT)
private Date createTime;
Save part in OrderDAO.
@SuppressWarnings("unchecked")
public T save(T object) {
return (T) super.getHibernateTemplate().merge(object);
}
every time, I just only get null.
--
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
17 years, 8 months
[Hibernate-JIRA] Created: (HHH-2442) ClassCastException loading from second level cache
by Marcio Moraes (JIRA)
ClassCastException loading from second level cache
--------------------------------------------------
Key: HHH-2442
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2442
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1, 3.2.2, 3.2.0.ga
Environment: Linux 2.6.15-27-686 #1 SMP PREEMPT Fri Dec 8 18:00:07 UTC 2006 i686 GNU/Linux
Reporter: Marcio Moraes
Priority: Blocker
I'm getting a error when using hibernate 3.2.2.ga with cache (JBoss-Cache) cluster.
When hibernate get a entity from second level cache it confuses the arrays of values against array of types.
So in some situations i got ClassCastException ...
Looking up CacheEntry code at assemble method i saw:
private static Object[] assemble(
final Serializable[] values,
final Object result,
final Serializable id,
final EntityPersister persister,
final Interceptor interceptor,
final EventSource session)
throws HibernateException {
//assembled state gets put in a new array (we read from cache by value!)
Object[] assembledProps = TypeFactory.assemble(
values,
persister.getPropertyTypes(),
session, result
);
The issue is values (Serializeble[]) is in wrong order compared with persister.getPropertyTypes() (Type[]).
If only one cache instance is running it doesnt occurs ...
I am using Linux.
Att,
Márcio Moraes
--
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
17 years, 8 months