I'm trying to populate two tables: a user table and a user visit history table.
The user table code is working fine, but the many table (uservisithistory) doesn't get populated.
I think it may be in the mapping files.
I have the PK generation set to automatic in MySQL with no nulls, etc.
Here are the mapping files:
Users Table
Here is the mapping for the user visit history (many side) table:
The code to create the many side I do inside a
test "main" method like this:
(see: "// add new visit history record" below)
The strange thing to me is that the mapping file I generated has a "Users" element in the many side.
I think the reason it might not be populating the many side is that it needs the foreign key to insert into the user visit history table. However, since the PK in the users table gets generated by MySQL automatically, I'm not sure how this works or why the code isn't populating the many side.
Does the code, having a Set in the users table, and a Users object in the uservisithistory table, look correct?
Any advice/suggestions would be greatly appreciated.
Thanks.
Mike