[
http://opensource.atlassian.com/projects/hibernate/browse/ANN-598?page=co...
]
Peter Royle commented on ANN-598:
---------------------------------
by using the database to do the "SET NULL" behaviour, one
gets a consistent behaviour across all database users (be them Hibernate, legacy app,
etc).
Maybe you're right, but unless something's changed since about 3.2.0, I found that
purely using SET NULL in the database left Hibernate squarely out of the loop (the
Hibernate cache would have no idea that the effected association had been nullified). We
still need a way of informing the Hibernate cache that a particular association will
be/has been nullified in the database as a result of deleting the associated entity. The
simplistic approach I implemented was to simply evict the associated entity from the
cache.
For stand-alone Hibernate applications I think the best we can hope for is to be able to
implement this in a way which is consistent across a single instance of the application,
the DB and any other applications which use the same database but don't heavily cache
entity state. Any other instances of applications which heavily cache entity state will be
left in the dark.
I think however that when it comes to using JPA within an application server the
consistency may be able to spread across all applications deployed on that (cluster of)
application server, if they can all be configured to utilise the same cache. Not entirely
sure about that one though. Anyone an expert on this?
Pete.
Add ON clause to @ForeignKey
----------------------------
Key: ANN-598
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-598
Project: Hibernate Annotations
Issue Type: New Feature
Components: binder
Reporter: Christian Bauer
More important than it sounds:
@org.hibernate.annotations.ForeignKey(name = "FK_FEED_DIRECTORY_ID")
I need ON CASCADE DELETE on many of my foreign keys, so I have to do this right now via:
<hibernate-mapping>
<database-object>
<create>
alter table FEED drop constraint FK_FEED_DIRECTORY_ID;
alter table FEED add constraint FK_FEED_DIRECTORY_ID foreign key
(DIRECTORY_ID) references NODE on delete cascade;
</create>
<drop></drop>
</database-object>
</hibernate-mapping>
This is a bit annoying, especially since @JoinColumn(columnDefinition) is also not an
option - I don't want to hardcode my HSQL datatypes.
So we should accept a parameter on @ForeignKey (I know that the Hibernate binder
doesn't have that notion at all, we need it in native Hibernate as well) that accepts
"[ON {DELETE | UPDATE} {CASCADE | SET DEFAULT | SET NULL}];" and does the right
thing during schema export.
--
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