[Hibernate-JIRA] Created: (HHH-4085) Specifying a select clause triggers the "query specified join fetching, but the owner..." exception
by Kent Tong (JIRA)
Specifying a select clause triggers the "query specified join fetching, but the owner..." exception
---------------------------------------------------------------------------------------------------
Key: HHH-4085
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4085
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.3.2
Environment: Kubuntu 9.04
Reporter: Kent Tong
An Order contains some OrderItem's. Each OrderItem contains a Product and a quantity. To retrieve the Orders, The following HQL works:
Code:
from Order o left join fetch o.items i join fetch i.product
However, if I specify the select clause:
Code:
select o from Order o left join fetch o.items i join fetch i.product
Then Hibernate will return an error:
Code:
Exception in thread "main" org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=Product,tableAlias=product2_,origin=items items1_,colums={items1_.p_id ,className=lab3.Product}}] [select o from lab3.Order o left join fetch o.items i join fetch i.product]
at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:217)
at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:727)
at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:551)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:645)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:251)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650)
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:597)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:342)
at $Proxy0.createQuery(Unknown Source)
at lab3.OnlineStoreApp.run(OnlineStoreApp.java:32)
at lab3.OnlineStoreApp.main(OnlineStoreApp.java:14)
The test code is shown below:
Code:
package lab3;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class OnlineStoreApp {
private SessionFactory factory;
private Session session;
public static void main(String[] args) {
new OnlineStoreApp().run();
}
public OnlineStoreApp() {
Configuration cfg = new Configuration();
cfg.configure();
factory = cfg.buildSessionFactory();
}
@SuppressWarnings("unchecked")
private void run() {
session = factory.getCurrentSession();
session.beginTransaction();
Order o = new Order();
o.getItems().add(new OrderItem(new Product("p1"), 10));
o.getItems().add(new OrderItem(new Product("p2"), 20));
session.save(o);
List<Order> orders = session
.createQuery(
"select o from Order o left join fetch o.items i join fetch i.product")
.list();
System.out.println(orders.size());
session.getTransaction().commit();
}
}
package lab3;
import java.util.ArrayList;
import java.util.List;
public class Order {
private Long internalId;
private List<OrderItem> items;
public Order() {
items = new ArrayList<OrderItem>();
}
public Long getInternalId() {
return internalId;
}
public void setInternalId(Long internalId) {
this.internalId = internalId;
}
public List<OrderItem> getItems() {
return items;
}
public void setItems(List<OrderItem> items) {
this.items = items;
}
}
package lab3;
public class OrderItem {
private Product product;
private int qty;
public OrderItem() {
}
public OrderItem(Product product, int qty) {
this();
this.product = product;
this.qty = qty;
}
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
this.qty = qty;
}
}
package lab3;
public class Product {
private Long internalId;
private String name;
public Product() {
}
public Product(String name) {
this();
this.name = name;
}
public Long getInternalId() {
return internalId;
}
public void setInternalId(Long internalId) {
this.internalId = internalId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">jdbc:h2:tcp://localhost/~/test</property>
<property name="hibernate.connection.driver_class">org.h2.Driver</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">false</property>
<mapping resource="Product.hbm.xml"/>
<mapping resource="Order.hbm.xml"/>
</session-factory>
</hibernate-configuration>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="lab3.Order" table="orders">
<id name="internalId">
<generator class="sequence"></generator>
</id>
<list name="items" cascade="save-update">
<key column="o_id"></key>
<list-index column="idx"></list-index>
<composite-element class="lab3.OrderItem">
<many-to-one name="product" column="p_id" cascade="save-update"></many-to-one>
<property name="qty"></property>
</composite-element>
</list>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="lab3.Product">
<id name="internalId">
<generator class="sequence"></generator>
</id>
<property name="name"></property>
</class>
</hibernate-mapping>
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-2374) setFetchMode() ignore incorect path
by Baptiste MATHUS (JIRA)
setFetchMode() ignore incorect path
-----------------------------------
Key: HHH-2374
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2374
Project: Hibernate3
Type: Bug
Versions: 3.2.0.ga
Environment: All DB I guess
Reporter: Baptiste MATHUS
This bug report is in fact a copy of the one that was already present in H2 : http://opensource.atlassian.com/projects/hibernate/browse/HB-763 . It does not seem to have changed in H3.
When calling setFetchMode("path", FetchMode.JOIN) on a criteria, even if the path is not correct, Hibernate does not complain. Its behaviour seems to be to simply ignore this bad path. I guess this should throw an exception. In fact, the bad thing of ignoring bad path is that if the developer was wrong specifying the path (typo, for example), then the join simply won't happen :-/.
I wrote a very simple testcase :
public void testFindClients()
{
Session session = HibernateUtil.currentSession();
session.beginTransaction();
Client c = (Client)session.createCriteria(Client.class).setFetchMode("foo", FetchMode.JOIN)
.setFetchMode("foo.bar", FetchMode.JOIN).uniqueResult();
session.getTransaction().commit();
}
My Client class has some relationships with other classes, but obviously none named "foo". The code above just issue the following select :
select
this_.ID as ID0_0_,
this_.nom as nom0_0_,
this_.prenom as prenom0_0_,
this_.age as age0_0_
from
Client this_
Thanks again for your great work, guys!
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-2344) Persistent collection queued operation ignored with lazy inverse one-to-many collection.
by Sebastien Robert (JIRA)
Persistent collection queued operation ignored with lazy inverse one-to-many collection.
----------------------------------------------------------------------------------------
Key: HHH-2344
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2344
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1
Environment: Hibernate 3.2.1
Reporter: Sebastien Robert
I load an Object that contains a lazy inverse collection (one-to-many).
Hibernate wrap my collection with a PersistentMap
There is objects in the collection in the database but in my case the PersistentMap is not yet initialized.
I perform a remove operation on the persistentMap with a known key of one of the objects.
The map is not initialized (and the relation is an inverse one-to-many) so the map queue the removeOperation.
I perform a get operation with the same key and the value is still returned.
If we look closer at what happened in the PersistentMap, it's look like this.
//*****
public Object remove(Object key) {
if ( isPutQueueEnabled() ) { // This returned true, the
// map is not yet
// initialized
Object old = readElementByIndex( key ); // This method triggered
// an initialization of the
// map.
// Queued operation are
// processed in the after
// init method
queueOperation( new Remove( key, old ) ); // The remove operation
// is queued.
return old;
}
....
//*******
When i perform the get operation on the map the map is now initialized. The get is processed by the underlying map and the value is returned. The queued operation is completely ignored.
Currently i fixed my code by performing a containsKey before the remove . The containsKey initialize the map and then the remove do not queue the operation. But by looking at all the PersistentCollection it seem that i may have the same problem using put and remove with other persistentCollection.
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-5017) "SettingsFactory" no longer checks for presence of "supportsGetGeneratedKeys" before calling it
by Steve Perkins (JIRA)
"SettingsFactory" no longer checks for presence of "supportsGetGeneratedKeys" before calling it
-----------------------------------------------------------------------------------------------
Key: HHH-5017
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5017
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Reporter: Steve Perkins
A number of users are experiencing Hibernate failures when using various combinations of Oracle JDBC driver versions and JDK versions. A sample stacktrace is below:
Initial SessionFactory Creaion Failed.java.lang.AbstractMethodError: oracle.jdbc.driver.OracleDatabaseMetaData.supportsGetGeneratedKeys()Z
Exception in thread "main" java.lang.ExceptionInInitializerError
at HibernateUtil.buildSessionFactory(HibernateUtil.java:27)
at HibernateUtil.<clinit>(HibernateUtil.java:17)
at EvenManager.createAndStoreEvent(EvenManager.java:33)
at EvenManager.main(EvenManager.java:26)
Caused by: java.lang.AbstractMethodError: oracle.jdbc.driver.OracleDatabaseMetaData.supportsGetGeneratedKeys()Z
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:123)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339)
at HibernateUtil.buildSessionFactory(HibernateUtil.java:23)
... 3 more
The basic issue is that the "supportsGetGeneratedKeys" method does not exist on the "oracle.jdbc.driver.OracleDatabaseMetaData" JDBC driver class for many versions of Oracle. Even if you use the "hibernate.jdbc.use_get_generated_keys" config property, Hibernate still makes a call to that method and execution still fails.
Up until version 3.2.7.GA of Hibernate, the code checked for the presence of "supportsGetGeneratedKeys" prior to calling it. The problem emerged with version 3.3.2.GA, where now Hibernate just calls the method without first verifying that it exists. If there was no functional reason for removing this safety-check, can we please re-insert it to prevent such failures?
A discussion of this issue can be found on the forums at: https://forum.hibernate.org/viewtopic.php?f=1&t=1002210&p=2427193#p2427193
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-3627) String Scalar Function CONCAT and operator || in HQL not working correctly with numeric values
by Eric Belanger (JIRA)
String Scalar Function CONCAT and operator || in HQL not working correctly with numeric values
----------------------------------------------------------------------------------------------
Key: HHH-3627
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3627
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.3.1
Environment: MS SQL 2005
Reporter: Eric Belanger
Priority: Minor
Since HQL translate the CONCAT and || to + in SQL, numeric values get added together instead of being converted to String and concanated. Also causes problems when concatenating a numeric with a string.
SELECT CONCAT(1, 2) FROM...
Returns 3 instead of '12'
SELECT CONCAT('TWO', 2) FROM ...
java.sql.SQLException: Conversion failed when converting the varchar value 'TWO' to data type int.
java.sql.SQLException: Conversion failed when converting the varchar value 'TWO' to data type int.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224)
at net.sourceforge.jtds.jdbc.TdsCore.isDataInResultSet(TdsCore.java:792)
at net.sourceforge.jtds.jdbc.JtdsResultSet.<init>(JtdsResultSet.java:146)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:424)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:693)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
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(AbstractListModel.java:130)
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:1101)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3319)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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
14 years, 4 months
[Hibernate-JIRA] Created: (HHH-2068) TransientObjectException : object references an unsaved transient instance ...
by Ales PROCHAZKA (JIRA)
TransientObjectException : object references an unsaved transient instance ...
------------------------------------------------------------------------------
Key: HHH-2068
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2068
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.cr4
Environment: Windows, Hibernate 3.2.0.cr4, Oracle 9.2.0.1
Reporter: Ales PROCHAZKA
Attachments: XTest.zip
I found this problem:
If I create new object 'o1', which associate another persistent object 'o2' and by calling saveOrUpdate Hibernate throws PropertyValueException,
then when I corresct this property and try call saveOrUpdate in another session (in which 'o2' was not saved or loaded) Hibernate throws TransientObjectException.
Please see attached code :-)
This is a log :
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: insert into T_TEST (A_POKUS, A_POKUS_LONG, CID, PK) values (?, ?, 3, ?)
Hibernate: insert into T_TEST3 (PK) values (?)
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: select hibernate_sequence.nextval from dual
org.hibernate.PropertyValueException: not-null property references a null or transient value: persistent.Test5.pokus
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:284)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:509)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:501)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:497)
at test.MainTest.test(MainTest.java:71)
at test.MainTest.main(MainTest.java:42)
org.hibernate.TransientObjectException: persistent.Test3
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2900)
at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:474)
at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:197)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:120)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:340)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at test.MainTest.test(MainTest.java:87)
at test.MainTest.main(MainTest.java:42)
Thanx
--
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, 4 months
[Hibernate-JIRA] Created: (ANN-755) Cascade operations don't take affect through a @CollectionOfElements
by Chris L (JIRA)
Cascade operations don't take affect through a @CollectionOfElements
--------------------------------------------------------------------
Key: ANN-755
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-755
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: Hibernate 3.2.5
Reporter: Chris L
Consider having three classes. The first is an @Entity called a View, which has a collection of @Embeddable Column objects. Column objects have an @ManyToOne relationship to a @Entity called Filter.
The three classes have a very straightforward mapping:
@javax.persistence.Entity()
@Entity(dynamicUpdate=true)
@Table(name="PORTFOLIO_VIEW")
class View {
....
@JoinTable(name="PORTFOLIO_VIEW_COLUMN",joinColumns={@JoinColumn(name="VIEW_ID")})
@IndexColumn(name="COLUMN_INDEX")
@Cascade(CascadeType.ALL)
@LazyCollection(LazyCollectionOption.FALSE)
@CollectionOfElements
private List<Column> columns;
....
}
@Embeddable
class Column {
....
@ManyToOne(fetch=FetchType.EAGER)
@Cascade(CascadeType.ALL)
@JoinColumn(name="FILTER")
@Target(FilterImpl.class)
private Filter filter;
....
}
@javax.persistence.Entity
@Entity(dynamicUpdate=true)
@Table(name="FILTER")
@DiscriminatorColumn(name="CLASS_NAME",length=255)
abstract class FilterImpl {
....
}
When I create a new view, with a new column and filter object, I should be able to save the view and have the @Cascade settings on the @CollectionOfElements and the @ManyToOne inside of Column take affect, and save the Filter. Instead, I get a TransientObjectException because the Filter hasn't been saved yet.
I know I could work around this by either making Column an Entity, or by adding code to save the Filter before saving the View. But it seems to me this is reasonable usage of an Embeddable.
This issue was originally part of a forum post http://forum.hibernate.org/viewtopic.php?t=987977
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-5142) Exception when initializing lazy @ManyToMany indexed collection containing not audited entities
by Vladimir Klyushnikov (JIRA)
Exception when initializing lazy @ManyToMany indexed collection containing not audited entities
-----------------------------------------------------------------------------------------------
Key: HHH-5142
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5142
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.5.1
Environment: Hibernate Core 3.5.1
Reporter: Vladimir Klyushnikov
Priority: Blocker
Attachments: testcase.zip
Hi,
I am getting exception when executing following code:
{code}
@Entity
@Audited
public class M2MIndexedListEntity {
...
@ManyToMany(cascade = CascadeType.ALL)
@OrderColumn(name="sortOrder")
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
private List<NotAuditedEntity> list = new ArrayList<NotAuditedEntity>();
}
@Entity
public class NotAuditedEntity {
...
}
...
M2MIndexedListEntity entity = (M2MIndexedListEntity) auditReader.createQuery()
.forRevisionsOfEntity(M2MIndexedListEntity.class, true, false)
.getSingleResult();
assertEquals(1,entity.getList().size());
{code}
Stack trace is the following:
{code}
java.lang.ClassCastException: testapp.NotAuditedEntity cannot be cast to java.util.Map
at org.hibernate.envers.entities.mapper.relation.lazy.initializor.ListCollectionInitializor.addToCollection(ListCollectionInitializor.java:67)
at org.hibernate.envers.entities.mapper.relation.lazy.initializor.ListCollectionInitializor.addToCollection(ListCollectionInitializor.java:39)
at org.hibernate.envers.entities.mapper.relation.lazy.initializor.AbstractCollectionInitializor.initialize(AbstractCollectionInitializor.java:67)
at org.hibernate.envers.entities.mapper.relation.lazy.proxy.CollectionProxy.checkInit(CollectionProxy.java:50)
at org.hibernate.envers.entities.mapper.relation.lazy.proxy.CollectionProxy.size(CollectionProxy.java:55)
{code}
I've attached a full test case. Unzip it, run *mvn test* and see test failing
--
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, 4 months