Mitesh Meswani wrote:
Dave wrote:
2) Need schema change for weblogcategory table to allow websiteid to
be null
and I'm reluctant to put commit this change into the Roller schema as
websiteid
is required for categories.
There is a circular dependency between WebsiteData and WeblogCategoryData.
This is due to following ManyToOne relationships
Class WebsiteData {
....
@ManyToOne WeblogCategoryData bloggerCategory
@ManyToOne WeblogCategoryData defaultCategory
....
}
Class WeblogCategoryData {
....
@ManyToOne WebsiteData website
....
}
Toplink puts WeblogCategoryData above WebsiteData in commit order hence
a shallow insert (that is website set as null at insert and updated
after insert of corresponding WebsiteData) is performed while inserting
an instance of WeblogCategoryData. This requires to change the table
definition for weblogcategory be changed to have column websiteid as
nullable. I have not yet gone through hibernate code to see how it
handles the situation but I think many other providers also might run
into the same issue as toplink.
This is a problem in Toplink or the JPA impl, not a problem with the
database table definition. Every category *must* be attached to a
weblog. If you look at the WebsiteData pojo you will also notice that
both of the category associations you mentioned are listed as nullable,
so you can insert a website with null default and blogger categories,
then create those categories, assign them to the website, and save them.
-- Allen