[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2792) Session.delete is validate all fields are null

Carl Allain (JIRA) noreply at atlassian.com
Mon May 5 12:54:34 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2792?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30120 ] 

Carl Allain commented on HHH-2792:
----------------------------------

I have the same question than you.

Why do Hibernate end up 

1) setting properties referencing deleted instances to null on a deleted entity
2) checking for nullability stuff (as 1) just broke everything)
3) if I put optional=true all over the place in my annotations, HB would pass 1) and 2) but fail with an attempted updated with null values on the deleted entities (deleted through cascading)

There is some weird code that seems to handle this kind of situation (updating a deleted entity), but the only difference is in logging!

<code>
DefaultFlushEntityEventListener:
...

	private boolean scheduleUpdate(final FlushEntityEvent event) {
		
		final EntityEntry entry = event.getEntityEntry();
		final EventSource session = event.getSession();
		final Object entity = event.getEntity();
		final Status status = entry.getStatus();
		final EntityMode entityMode = session.getEntityMode();
		final EntityPersister persister = entry.getPersister();
		final Object[] values = event.getPropertyValues();
		
		if ( log.isTraceEnabled() ) {
			if ( status == Status.DELETED ) {
				log.trace(
						"Updating deleted entity: " +
						MessageHelper.infoString( persister, entry.getId(), session.getFactory() )
					);
			}
			else {
				log.trace(
						"Updating entity: " +
						MessageHelper.infoString( persister, entry.getId(), session.getFactory()  )
					);
			}
		}

</code>

I don't understand why these things are done this way and it does not seem there is a good documentated explanation for it (forum, book, PDF, etc.).


> Session.delete is validate all fields are null
> ----------------------------------------------
>
>                 Key: HHH-2792
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2792
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>            Reporter: Daniel Passos
>
> session.delete operation would not have to validate if the fields are null
> The problem in DefaultDeleteEventListener.deleteEntity -> Nullability.checkNullability

-- 
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list