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 726697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:28:53+00:00 2026-05-14T06:28:53+00:00

I have a class Player that contains a list of Accessory objects. There are

  • 0

I have a class Player that contains a list of Accessory objects. There are two kinds of Accessories. SocketedAccessories have a list of SocketJewels, and MagicAccessories have a list of MagicEnchantments.

At the database level, there is a players table that represents the player, and an accessories table that contains a list of accessories. Accessories have a type field that indicates whether they are socketed or magical, and the columns that are only used by one type are just left blank by entries of the other type. There are socket_jewels and magic_enchantments tables, representing the socket jewels or the magic enchantments on each accessory.

I am trying to figure out the correct way to map this with Hibernate. One way would be for the player to have two lists of accessories, one for SocketedAccessories and one for MagicAccessories. That seems undesirable, though. What I want is a way to specify that player should have a field List<Accessory> accessories that contains both types of thing.

Is there a way to tell Hibernate, in either hbm.xml or annotations, to do this?

  • 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-05-14T06:28:54+00:00Added an answer on May 14, 2026 at 6:28 am

    Is there a way to tell Hibernate, in either hbm.xml or annotations, to do this?

    What you’re describing looks like a Single Table per Class Hierarchy Strategy (all properties of all super- and subclasses are mapped into the same table, instances are distinguished by a special discriminator column).

    You can map this with annotations and/or xml mappings (and have a single List, Hibernate supports polymorphic queries i.e. you can query on the Accessory superclass and get a list of subclasses).

    Update: If Accessory is an interface, have a look at this previous answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that contains player numbers... public class Game { public int
I have class method that returns a list of employees that I can iterate
I have a Player class that uses a ForeignKey to a Photo object for
Hi I have created a List of Objects. Each object contains a Set. I
I have a class Player that is a subclass of UIImageView. They are spawned
I have a window that contains a label (player1). I also have a class
I have a Player class that derives from Humanoid and Humanoid derives from Sprite
I have a Club class and a Player Class. The player class has an
i have the following models setup class Player(models.Model): #slug = models.slugField(max_length=200) Player_Name = models.CharField(max_length=100)
I have a vector called players and a class called Player. And what I'm

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.