Reputation: 1083
I have two tables in my database USERS, and USER_SESSIONS. USER_SESSIONS has a foreign key on userid that maps to the USERS table's userid, and I have defined the many-to-one relationship in hibernate with:
<many-to-one name="user" column="USERID" class="com.Users" />
How do I write a hibernate method to delete all rows in the USER_SESSIONS database for a given user when only given the username.
My first attempt was to load the user object for the given username, and then do an HSQL to delete all sessions for that user's userid. Is there a simpler way?
Upvotes: 0
Views: 1408
Reputation: 34367
I think one other way could be as:
delete
on the relationshipUpvotes: 2