[Hibernate-JIRA] Created: (HHH-2920) Polymorphic association with explicit table_per_class strategy: properties of subclass are not retrieved by queries.
by Andrea Silva (JIRA)
Polymorphic association with explicit table_per_class strategy: properties of subclass are not retrieved by queries.
--------------------------------------------------------------------------------------------------------------------
Key: HHH-2920
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2920
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.5
Environment: Java 1.5 - Hypersonic DB - Standalone application
Reporter: Andrea Silva
Priority: Minor
Attachments: src.zip
Item class has a one-to-many association to Bid. Bid class has a subclass called CashBid (meaningless design I know, but that's not the point). If I create and save an instance of Item with an associated CashBid, when I query for items the properties defined in CashBid are not retrieved.
NB Bid is not mapped as abstract.
Here is a code snippet:
...
// First Session
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
Bid bid = new CashBid(new BigDecimal(100.0d), "euro");
Item item = new Item("pc");
Serializable bidId = session.save(bid);
item.addBid(bid);
session.save(item);
transaction.commit();
session.close();
// Second Session
session = sessionFactory.openSession();
transaction = session.beginTransaction();
//session.load(CashBid.class, bidId);
Query query = session.createQuery("from Item");
List<Item> list = query.list();
for (Item item_ : list) {
System.out.println(item_);
}
transaction.commit();
session.close();
...
The bid in the item retrieved by the query is a CashBid (that's correct) but the properties that are defined in CashBid and not in Bid are null. If I uncomment the line
//session.load(CashBid.class, bidId);
the problem is not there anymore.
If Bid is not mapped as abstract the problem doesn't show.
My apologies if I'm just missing something very obvious.
Please find the source code and the mappings attached.
--
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, 1 month
[Hibernate-JIRA] Created: (HHH-2801) wrong insert/delete order when updating record-set
by Christoph Mayerhofer (JIRA)
wrong insert/delete order when updating record-set
--------------------------------------------------
Key: HHH-2801
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2801
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.4.sp1
Environment: hibernate-3.2.4.sp1, hibernate-annotations-3.3.0.GA, hibernate-entitymanager-3.3.1.GA, Oracle 10g Express Edition
Reporter: Christoph Mayerhofer
Attachments: model.zip
Overview: I have a record with a OneToMany association. From this associated record-set a record is removed and added again, both records identified with the same key. When doing a merge, I get a Unique constraint violation, because Hibernate first tries to insert the new record. Hibernate should first delete the old record, and after this insert the new record, avoiding the unique constraint violation.
Detailed description: I have the following entities: Patient, SocialInsurance, PatientSocialInsurance. A patient could have several social insurances assigned to it. A social insurance could be assigned several times to a patient, we have a m:n relation between Patient and SocialInsurance. The relation-table has the name PatientSocialInsurance, with a unique constraint over patient_id and social_insurance_id. Each POJO inherits from a Base-POJO, which holds the id and the insert- and update-timestamps and userstamps.
Base ---> PatientEntity ---> Patient
Base ---> SocialInsuranceEntity ---> SocialInsurance
Base ---> PatientSocialInsuranceEntity ---> PatientSocialInsurance
Note: All *Entity model objects are generated with Hibernate-Tools from the db-schema, assuming that there are no wrong annotations, no wrong fields or wrong getter-/setter-methods in these model-classes.
(I have enclosed all model-classes within an zipped attachment.)
Now I try to delete an existing social insurance from a patient and add the same social insurance to the patient again:
public void deleteSocialInsurance(Patient p, PatientSocialInsurance s) {
if (p == null || s == null) {
throw new IllegalArgumentException();
}
s.setSocialInsurance(null);
s.setPatient(null);
p.getPatientSocialInsurances().remove(s);
}
public void addPatientSocialInsurance(Patient p, PatientSocialInsurance s)
throws DuplicatePatientSocInsException {
if (p == null || s == null) {
throw new IllegalArgumentException();
}
s.setPatient(p);
p.getPatientSocialInsurances().add(s);
}
After doing a merge on the patient object, I get the following error:
DEBUG - persisting patient...
DEBUG - transaction org.hibernate.ejb.TransactionImpl@44ac6a started
DEBUG - update timestamp and userstamp for base record set
DEBUG - update timestamp and userstamp for base record set
DEBUG - update timestamp and userstamp for base record set
DEBUG - update timestamp and userstamp for base record set
DEBUG - update timestamp and userstamp for base record set
DEBUG - select rawtohex(sys_guid()) from dual
DEBUG - insert timestamp and userstamp for base record set
DEBUG - insert into dseas.PATIENT_SOCIAL_INSURANCE (TIME_CRE, TIME_UPD, USER_CRE, USER_UPD, CODE_MEMBERSHIP_NO, CODE_TYPE_DEFAULT, PATIENT_ID, SOC_INS_ID, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
ERROR - ORA-00001: Unique Constraint (DSEAS.PATIENT_SOCIAL_INSURANCE_UK) verletzt
ERROR - ORA-00001: Unique Constraint (DSEAS.PATIENT_SOCIAL_INSURANCE_UK) verletzt
ERROR - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
at org.dseas.base.hibernate.EntityManagerFacade.commit(EntityManagerFacade.java:78)
at org.dseas.business.service.maindata.PatientEditorService.save(PatientEditorService.java:112)
at org.dseas.ui.rcp.editor.patient.PatientEditorPart.doSave(PatientEditorPart.java:1298)
at org.eclipse.ui.internal.SaveableHelper$1.run(SaveableHelper.java:143)
at org.eclipse.ui.internal.SaveableHelper$4.run(SaveableHelper.java:266)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:369)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:313)
at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:758)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:755)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2451)
at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:274)
at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:253)
at org.eclipse.ui.internal.SaveableHelper.savePart(SaveableHelper.java:148)
at org.eclipse.ui.internal.EditorManager.savePart(EditorManager.java:1345)
at org.eclipse.ui.internal.WorkbenchPage.savePart(WorkbenchPage.java:3184)
at org.eclipse.ui.internal.WorkbenchPage.saveEditor(WorkbenchPage.java:3197)
at org.eclipse.ui.internal.SaveAction.run(SaveAction.java:73)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:545)
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.dseas.ui.rcp.Application.start(Application.java:22)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
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:504)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443)
at org.eclipse.equinox.launcher.Main.run(Main.java:1169)
at org.eclipse.equinox.launcher.Main.main(Main.java:1144)
Caused by: java.sql.BatchUpdateException: ORA-00001: Unique Constraint (DSEAS.PATIENT_SOCIAL_INSURANCE_UK) verletzt
at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10657)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 55 more
ERROR - Error while commiting the transaction
--
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, 1 month
[Hibernate-JIRA] Created: (HBX-757) Add output file name, delimiter, halt on error, and format options to SchemaUpdate/<hbm2ddl>
by Dan Ports (JIRA)
Add output file name, delimiter, halt on error, and format options to SchemaUpdate/<hbm2ddl>
--------------------------------------------------------------------------------------------
Key: HBX-757
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-757
Project: Hibernate Tools
Type: Improvement
Components: ant
Versions: 3.2beta7
Reporter: Dan Ports
Priority: Minor
The file name, delimiter, halt on error, and format options are provided by SchemaExport/<hbm2ddl> already, so it makes sense to add their functionality to SchemaUpdate as well. I'll submit a patch shortly. (Is this the right place to post this, since SchemaUpdate is in the Hibernate core SVN?)
--
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, 1 month
[Hibernate-JIRA] Created: (HHH-2310) LazyInitializationException: Initializing many-to-one and one-to-one associations to a maximum of max-fetch-depth fails when using a SQLProjection on a Criteria generated Query
by Nico De Groote (JIRA)
LazyInitializationException: Initializing many-to-one and one-to-one associations to a maximum of max-fetch-depth fails when using a SQLProjection on a Criteria generated Query
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2310
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2310
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.0.5
Reporter: Nico De Groote
Priority: Critical
Initializing many-to-one and one-to-one associations to a maximum of max-fetch-depth fails when using a SQLProjection on a Criteria generated Query
Following scenario occurs.
I have a max-fetch-depth = default value.
I have a the following businessobject having the following associations.
BO -> BO2 (One to one)
BO -> list of BO3 (one to many)
I want to query for BO objects with the where clause containing a condition on one of the properties of the BO3 objects.
When I now generate my query via the Criteria API and having the following projection set to retrieve only my BO objects (and none of the outer joinables)
Projection projection = Projections.sqlProjection(
"{alias}." + primaryKeyColumn + " theObj__", new String[]{"theObj__"},
new Type[]{Hibernate.entity(BO.getClass())});
I get my BO objects but the BO2 object is not initialized, as it should ne because of the max-fetch-depth.
When not using the Projection I do get the one-to-one relation (BO2 object) as the max-fetch-depth is default value, but the query takes too much time because of the non required properties for the outerjoinable associations in the select clause.
It seams that the fetching of the many-to-one and the one-to-one associations for the max-fetch-depth is disabled when using projections.
Or am I missing the point here?
--
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, 1 month
[Hibernate-JIRA] Created: (HV-42) Reference Documentation: broken example
by Robert Spielmann (JIRA)
Reference Documentation: broken example
---------------------------------------
Key: HV-42
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-42
Project: Hibernate Validator
Issue Type: Bug
Components: documentation
Reporter: Robert Spielmann
Priority: Trivial
The Hibernate Validator Reference Guide (Hibernate Validator 3.0.0.GA) contains examples for writing custom annotations and validators, section 1.4 "writing your own constraints". There, it says that the class CapitalizedValidator implements Validator<Capitalized> and PropertyConstraint. The example class, however, does not implement the "apply" method. Thus, the example class does not compile.
Additionally, the class "Capitalize" (containing constants like FIRST) is not defined anywhere. This leaves the example incomplete and thus - unless you quickly implement this class - unsuable for practical experiments.
--
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, 1 month