Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8762675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:35:29+00:00 2026-06-13T15:35:29+00:00

I have two tables in my database USERS, and USER_SESSIONS. USER_SESSIONS has a foreign

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:35:30+00:00Added an answer on June 13, 2026 at 3:35 pm

    I think one other way could be as:

    1. Define cascade as delete on the relationship
    2. Load user entity
    3. Remove all the user session object from user
    4. Save user entity back.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My database has two tables: Users UserId PK Likes LikeId PK LikedUserId FK LikingUserId
Let's say that I have two tables in my database: users countries I have
I have two tables in database: comments table users table | u_id | text
I have two tables in my database: user and media_contact . The media_contact table
I have two database tables with the following structure: actions: action_id int(11) primary key
I have two tables in my database schema that represent an entity having a
I have two tables in my database that look like that: Customer: C_ID city
i have two tables in my database : Users : contain user information UserTypes
Have have two tables in two different databases: Lets say i have Database users
I have two tables in my database who looks like this: User: userid(int) username(varchar)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.