jointable

Multiple @ManyToMany sets from one join table

Hi guys, I'm mapping a proprietary database to Hibernate for use with Spring. In it, there are a couple of jointables that, for entity A and entity B have the following schema: CREATE TABLE AjoinB ( idA int not null, idB int not null, groupEnum enum ('groupC', 'groupD', 'groupE'), primary key(idA, idB, groupEnum) ); As you ca...

Hibernate: How can I join 2 classes in one table?

So, I'm pretty new to Hibernate and I have a problem. I have an abstract class (the super-class, class Super), and 5 subclasses which should use the proprieties from the class Super and add a new propriety (a new column) So how can I do this? Should I extend the class Super from java, or it's enough to join the classes using a JPA anno...

JPA Secondary Table Issue

I have a three tables: User, Course, and Test. Course has a User foreign key and Test has a Course foreign key. I am having trouble mapping the Test collection for each User since I need an intermediary step from User -> Course -> Test. I am trying to use a SecondaryTable since the User key for the Test is its associated Course row. A...

Modeling a Join Table

Hi, I have the following database model: [User] Id Name [Role] Id Name [UserRole] UserId RoleId IsActive And I want to create a nice way to represent this relationship and the property that is in it with objects without creating a class to represent UserRole table. Any ideas? Thanks a lot! ...

Using Restrictions.disjunction over @JoinTable association

This is similar, but not identical, to: http://stackoverflow.com/questions/1528352/hibernate-criteria-query-on-different-properties-of-different-objects I have a SpecChange record, which has a set of ResponsibleIndividuals; these are User records mapped by a hibernate join-table association. I want to create a Criteria query for a Spec...

Polymorphic Join Table in Rails?

In my app, an Event has multiple items associated with it, potentially all of different types. For example, a "User ate a Banana" Event would have a User and a Banana associated with it. It seems like one way to accomplish this would be to have a polymorphic join table with 3 fields: event_id, attachable_type, and attachable_id, where ...

Self referencing symmetrical Hibernate Map Table using @ManyToMany

I have the following class public class ElementBean { private String link; private Set<ElementBean> connections; } I need to create a map table where elements are mapped to each other in a many-to-many symmetrical relationship. @ManyToMany(targetEntity=ElementBean.class) @JoinTable( name="element_elements", joinColumns=@Jo...

Does @JoinTable has a property of "table" or not?

The following is copied from hibernate's document. (http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#d0e2770) @CollectionOfElements @JoinTable( table=@Table(name="BoyFavoriteNumbers"), joinColumns = @JoinColumn(name="BoyId") ) @Column(name="favoriteNumber", nullable=fals...

Buddy List: Relational Database Table Design

So, the modern concept of the buddy list: Let's say we have a table called Person. Now, that Person needs to have many buddies (of which each buddy is also in the person class). The most obvious way to construct a relationship would be through a join table. i.e. buddyID person1_id person2_id 0 1 2 1 3 ...

In Rails how does one find disassociated records in a HABTM relationship?

I have a HABTM relationship between Videos and Campaigns in Rails which means the association is stored in a join table. I want to find all the Videos that do NOT have an associated campaign. What would be the most efficient way of doing this? Thank you for looking =) ...

What does a Hibernate join table class using composite keys and @NaturalId look like?

I found this before: http://stackoverflow.com/questions/1212058/how-to-make-a-composite-primary-key-java-persistence-annotation There's a code snippet on the first answer: @Entity public class UserRole { @Id @GeneratedValue private long id; @NaturalId private User user; @NaturalId private Role role; } So, not using ar...

How to delete all associations in a Hibernate JoinTable at once?

We have the following two entities with many-to-many association: @Entity public class Role { ... @ManyToMany @JoinTable( name = "user_has_role", joinColumns = { @JoinColumn( name = "role_fk" ) }, inverseJoinColumns = { @JoinColumn( name = "user_fk" ) } ) private Set<User> userCollection; ... } and @Entity publi...

Hibernate - how to model triple join table as map?

Hi! I have a problem with mapping triple join table as a map with Hibernate using annotations. I have 3 tables: project, group, role and triple join table project_group_role with columns project_id, group_id, role_id (primary key is a pair of project_id and group_id). Database structure is given strictly from supervisor, so it would be g...

Storage of different data formats in Rails dynamically defined by admin

I'm facing a problem where I cannot permanently decide which columns one of my models will have. A use case will be this: An admin creates a new dataset, he wants users to answer. In the dataset the admin defines several data points of different format and units. I could imagine the classes to look similar to this: class Dataset < ...

Rails 3 nested forms with has_many :through, entry in join table dosen't get deleted after update

Hi, i have a 'User' model which has a has_many relationship to a 'Number' model through a join table 'user_number' model. I use accepts_nested_attributes_for :numbers, :allow_destroy => true in the 'User' model. Everything works fine except that whenever i delete a number from a user in the edit form, the associated number is deleted ...