hibernate-onetomany

Hibernate performance issue with OneToMany / nullable relationship

We use @OneToMany for our Parent->Child->Child->Child DB relationship: @OneToMany(cascade = CascadeType.ALL) @JoinColumn(name = "THE_ID", nullable = false ) private List<ChildClass> children = new ArrayList<ChildClass>(); We have a scenario with a lot of data (100K inserts) where the performance is atrocious (actually times out) when ...

Castle ActiveRecord DetachedCriteria Performance For One To Many Criteria, or just use SubQuery.In

When querying into child collections should I be wary of performance and duplicate results which result from the use of CreateAlias("ChildCollectionName", "alias") would you think it would be better to just perform subqueries on Child Collections to get a big list of "parentId"s and then do an In clause on the parent. For Example clas...

Hibernate mapping, on a unmapped class

Hi, I' ve got 2 tables... Challenge and ChallengeYear, ChallengeYear is only to create a list of years in challenge. I only want to make Challenge an entity, containing a list of List years. Is this possible? I've looked in to @SecondaryTable together with @JoinColumn and @OneToMany, but neither of those can do the trick, or i am ove...

why when I delete a parent on a one to many relationship on grails the beforeInsert event is called on the child??

hello, I have a one to many relationship and when I try to delete a parent that haves more than one child the berforeInsert event gets called on the frst child. I have some code in this event that I mean to call before inserting a child, not when i'm deleting the parent! any ideas on what might be wrong? the entities: class MenuItem {...

Lost with hibernate - OneToMany resulting in the one being pulled back many times..

I have this DB design: CREATE TABLE report ( ID MEDIUMINT PRIMARY KEY NOT NULL AUTO_INCREMENT, user MEDIUMINT NOT NULL, created TIMESTAMP NOT NULL, state INT NOT NULL, FOREIGN KEY (user) REFERENCES user(ID) ON UPDATE CASCADE ON DELETE CASCADE ); CREATE TABLE reportProperties ( ID ...

CascadeType problem in One to Many Relation

Hi I have two classes which have a Unidirectional One to Many relation with each other. public class Offer{ ... @OneToMany(cascade=CascadeType.ALL) @JoinTable(name = "Offer_Fields", joinColumns = @JoinColumn(name = "OFFER_ID"), inverseJoinColumns = @JoinColumn(name = "FIELDMAPPER_ID")) private Set<FieldM...

Hibernate : OneToMany mapping not based on PK ?

I have 2 entities/tables. One is a proper entity, let's call it data. It has a number of fields containing so-called "multilingual codes". The second table, code, contains the multilingual values themselves. Here is some example data : Data table id name continentCode countryCode ------------------------------------ 1 ...

Grails AddTo in for loop

I am facing a problem due to that i'm newbie to grails i'm doing a website for reading stories and my goal now is to do save the content of the story into several pages to get a list and then paginate it easily .. so i did the following. in the domain i created two domains one called story and have this : class Story { String title ...

Hibernate: How do I write the HQL for getting records of an entity without records for its identifying relation

I have Hibernate Objects defined as Class SomeText{ private Long textId; private Set<Tag> Tags = new HashSet<Tag>(); @ManyToMany(cascade={CascadeType.PERSIST,CascadeType.MERGE }) @JoinTable(name = "text_tag_reln", joinColumns = { @JoinColumn(name = "textId") }, inverseJoinColumns = { @JoinColumn(name = "tagId") }) pu...

Hibernate One to many

As per hibernate documentation: To map a bidirectional one to many, with the one-to-many side as the owning side, you have to remove the mappedBy element and set the many to one @JoinColumn as insertable and updatable to false. This solution is not optimized and will produce some additional UPDATE statements. @Entity public class...

Hibernate: joining with one of the keys of a multi-keyed table

Hi guys, I've got a table Category and a table TranslatableText. The category is like this create table Category ( id int not null, parent_id int default 0, TranslatableDescriptionId int default 1, primary key(id)); create table TranslatableText ( id int not null, lang enum ('NO','EN','FR'), text mediumtext, primary ke...

Hibernate - OneToMany - Several Columns

Hello there, I have those 2 tables Teacher and Contact, a teacher can have x Contacts SO here we are looking at a @OneToMany association. Tables Structure: User [userid, username, email,...] Contact [contactid, contactname, ref, reftype,...] I want to load from my User Class all the User's contacts. To do that I would do a query lik...