OneToMany 4 « Map « JPA Q&A





1. Hierarchy and OneToMany mapping    forum.hibernate.org

@Entity @Table(name = "element_field") @org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true) @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING) @AttributeOverride(name = "type", column = @Column(name = "type", nullable = false, insertable = false, updatable = false)) @SequenceGenerator(name = "ELEMENT_FIELD_SEQ", sequenceName = "element_field_id_seq", allocationSize = 1) public abstract class ElementField extends DomainEntity { ... ...

2. @OneToMany stacktrace with insertions    forum.hibernate.org

@JoinTable( name = "subscription_histories", joinColumns = @JoinColumn(name = "event_id"), inverseJoinColumns = @JoinColumn(name = "subscription_history_id") ) @OneToMany(cascade = {CascadeType.MERGE, ...

3. [SOLVED]Use of @OneToMany or @ManyToMany    forum.hibernate.org

Newbie Joined: Tue May 03, 2011 12:28 am Posts: 2 Hi, I'm new to Hibernate, recently I've been learning Hibernate with Struts and Spring, when I tried to write my first app, I encountered the problem: Quote: Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: data.Movie.actors[data.Actor] at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1185) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:710) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:645) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:65) at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1689) at ...

4. OneToMany Foreign Key not being persisted    forum.hibernate.org

Hi, I have a simple oneToMany relationship which I am trying to map with annotations. I have two tables, ACCOUNT and USER, and two model objects, Account and User. Account has a set of User objects which are related to the account by an account_id foreign key. My schema looks like this - Code: ACCOUNT (ID) USER(ID, ACCOUNT_ID, USERNAME) Where ACCOUNT_ID ...

5. OneToMany Problem    forum.hibernate.org

1.New a Web Project test with MyEclipse 8.6. 2.Add jars(Hibernate 3.6.4) as follows: antlr-2.7.6.jar commons-collections-3.1.jar dom4j-1.6.1.jar hibernate3.jar hibernate-jpa-2.0-api-1.0.0.Final.jar javassist-3.12.0.GA.jar jta-1.1.jar slf4j-api-1.6.1.jar mysql-connector-java-5.1.12-bin.jar commons-logging-1.1.1.jar 3.Person.java Code: package cn.mall.domain.user; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToMany; @Entity public class Person { private Long id; private String name; ...

7. OneToMany relationship and orphanRemoval attribute    forum.hibernate.org

Newbie Joined: Tue Jun 07, 2011 4:53 pm Posts: 2 Hi friends, I need your help... :) I developing an application in spring mvc and hibernate3. The configuration of hibernate classes are the next... Code: @Entity @Table(name="TDE_DECLARACION") @SequenceGenerator(name="SEQ_DECLARACION", sequenceName="DECLARACION_ID") public class Declaracion{ private int codigo; private int tipo; ...

8. Criteria and OneToMany property    forum.hibernate.org

select distinct b1_.id as id8_, b1.last_changed as last3_8_ from public.a a0_ inner join public.b b1_ ...

9. Problem with @ManyToOne/@OneToMany    forum.hibernate.org

Newbie Joined: Fri Jun 17, 2011 8:18 am Posts: 2 Hi @all, i've a problem with hibernate and a @ManyToOne/@OneToMany-relation and don't know how solve it. The following Exception occures and I don't know why: Exception in thread "main" org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: de.hfu.wi.aam.sa.calendar.persistence.entities.CalendarUser.lstTasks[de.hfu.wi.aam.sa.calendar.persistence.entities.Task] The message only occures for the relation between the class Task ...





10. OneToMany.Persist will fails because of a detached reference    forum.hibernate.org

Hi again, I have some trouble with calling .persist(). This will lead on the following testcase into this Exception: org.hibernate.PersistentObjectException: detached entity passed to persist: Faculty The two comments will fix the exception but i don't like the way they to this. Code: public class CreateTimetableTest { @PersistenceContext EntityManager entityManager; ...

11. OneToMany JPA self-reference through JoinTable    forum.hibernate.org

I'm fairly new to JPA and am trying to figure out something that seems pretty basic to me. I feel like I'm probably missing something simple that I should be seeing. I have two tables: county and adjacent_counties. One table represents the counties and the other is a relationship table that links counties throughout the country that are adjacent (even if ...

12. Mapping two classes with @OneToMany in a table    forum.hibernate.org

Newbie Joined: Mon Jun 06, 2011 7:39 am Posts: 3 Hi, I'm pretty a newbie with mapping technologies, and i have a problem with mapping two tables in a single class. My problem is as follows: I want to implement i18n functionalities at database level for the countries, places, ... and any other geographical data that may be stored in the ...

13. Select from 2 tables, Hibernate, onetomany with Criteria.    forum.hibernate.org

I am learning Hibernate and I need help with an issue I have the following tables %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @Entity public class College { @Id @GeneratedValue private int collegeId; private String collegeName; @OneToMany(targetEntity=Student.class, mappedBy="college", cascade=CascadeType.ALL, fetch=FetchType.EAGER) private List students; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @Entity public class Student { @Id @GeneratedValue private int studentId; private String studentName; @ManyToOne @JoinColumn(name="college_id") private College college; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% I have the following ...

14. OneToMany - overwrite existing children    forum.hibernate.org

Hi, I'm not sure how to solve the following problem. Maybe you can help me. I have a OneToMany association (bidirectional) between to classes which looks like this Code: class Parent { ... /*** 1:n Child***/ @OneToMany(targetEntity = Child.class, fetch = FetchType.LAZY, mappedBy = "parent") ...

16. OneToMany HIbernate Projections problem    forum.hibernate.org

I'm trying to create a Hibernate projection for database stored File and its versions like this: Code: DetachedCriteria criteria = DetachedCriteria.forClass(File.class, "file"); criteria.createAlias("versions","versions", CriteriaSpecification.LEFT_JOIN); criteria.createAlias("publishedVersion","publishedVersion", CriteriaSpecification.LEFT_JOIN); criteria.setProjection( Projections.projectionList() ...





17. Common target of @OnetoMany relation    forum.hibernate.org

Newbie Joined: Mon Jul 18, 2011 11:23 am Posts: 4 Hi, Hibernate version - 3.6.1.FINAL DB - MySQL I have the following relationship among entities - Amount has one or more TaxAmount Tax has one or more TaxAmount ,there is no relation ship b/w Amount and Tax. The entities are are as follows - 1) Amount Code: package com.uti.entity; import java.io.Serializable; ...

18. OneToMany with composite primary key not working    forum.hibernate.org

Hello All - Wondering if someone can help me. Here's my setup briefly. I have a OneToMany between a Challenge and Participants. The challenge has a auto-increment PK id. The Participants have a composite primary key between an id (from challenge's PK) and user_email. Participants also has a FK to Challenge's id. -------------------------- Challenge Table id_challenge - PK Auto-Increment -------------------------- Participants ...

19. Accessing collections with OneToMany Bidirectional Mapping    forum.hibernate.org

Newbie Joined: Tue Oct 04, 2011 11:06 am Posts: 1 Please forgive me for posting this 'beaten to death' problem. I literally tried tens of solutions posted here as well as the Spring/Hibernate forums to no avail. I have a feeling that I am not wiring the beans properly as none of the solutions I tried worked. My problem is, after ...

20. Query by example / Criteria API with OneToMany relation    forum.hibernate.org

Hi, I have an entity "User", which has a OneToMany relationship to its communication data. Code: @Entity public class User { .... @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) public Set getCommunicationData() { return communicationData; } ...

21. Strange behaviors in @OneToMany relationship.    forum.hibernate.org

I'm trying to create a simple Parent/Child relationship with the JPA 2 API and Hibernate 3.6.7 or 4.0.0.CR4 as a provider, and I discovered some strange behaviors which can be reproduced on a simple setup. In a nutshell I have two entities: Parent and Child both using embeded keys ParentKey and ChildKey. The definitions follow: Code: @Embeddable public class ChildKey ...

22. OneToMany: Unidirectinal mapping: Bug or Mistake?    forum.hibernate.org

Hi, I'm getting the following exception when I try to persist an OneToMany unidirectional: java.sql.SQLException: Field 'id_funcionario' doesn't have a default value The field 'id_funcionario' is the foreign key and is defined as not null. If this field is defiined as nullable works. Below are the classes and the DDL. Code: @Entity public class Funcionario implements Serializable { ...

23. How to map a Map in hibernate with @OneToMany relation ?    forum.hibernate.org

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinTable(name = "perm_cat_map", joinColumns = { @JoinColumn(name = "perm_cat_id") }, inverseJoinColumns = { @JoinColumn(name = "permission_id") }) private Map permissions = new ArrayList(0);

24. @OneToMany primary key part of foreign key    forum.hibernate.org

I'm a newbe and have a simple @OneToMany relationship to build without using a Join-Table and where the PK of table 1 is part of the PK in table 2 table 1: Exchange , PK: id table 2: ExchangeRetrievalDate, PK: exchangeId (Pk of Exchange) + date @Entity public class Exchange { @Id private Integer id; @Column private String code; @OneToMany(cascade = ...

25. Hibernate OneToMany abstract Class override id    forum.hibernate.org

I'm using JPA 1.0 so I am limited in what I can do but I still think it should be possible to do the following however I cant get it working... Code: Table CustomerA a_id Table ProductB a_id b_id Table ProductC a_id c_id @Entity @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) public abstract class AbstractProduct ...

26. multiple @OneToMany to a class    forum.hibernate.org

Hi, Im trying to define multiple OneToMany Relationships to the same class and I do not know what is the best way to do it. I have classses A and B: class A{ long id; List leftList; List rightList; } B would be OPTION 1 class B{ long id; A leftA; A rightA; } or OPTION 2 class B{ long id; ...

27. Unit Testing Exception OneToMany.orphanRemoval()Z    forum.hibernate.org

Hi everyone, I have a web application spring + hibernate based and it run/works well. But when I try to test it via unit test, I got the "Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z" this exception. I read a lot of about this problem, all people say it come due to JPA1 and place JPA2 on your classpath. But I don't have any ...

28. Problems with multi-select query and OneToMany relation    forum.hibernate.org

Hi, I want to apply a multiselect query to an Entity with a OneToMany Relation. The Entity looks like this: Code: @Entity @Table(name = "TRAVEL_ENTITY") public class TravelEntity { // instance data private UUID uuid; private String description = ""; private Set ...

29. OneToMany - Where Clause Question    forum.hibernate.org

30. Help with Bidirectional OneToMany List using Annotations    forum.hibernate.org

I'm having some trouble mapping a bidirectional one to many list using Hibernate 3.0.5, Annotations Beta 2, and hsqldb 1.7.2. Specifically, the index column is null for every new record. What have I done incorrectly? Code: @Entity public class FieldTypeAttribute { ... @ManyToOne @JoinColumn(name="fieldTypeAttribute_id") public FieldType getType() { ...

31. Newbie question concerning oneToMany    forum.hibernate.org

32. OneToMany is not persisting children    forum.hibernate.org

Hibernate version: 3.1, Annotations 3.1 beta 8 Problem: Parent object contains children. I want to persist changes from the parent to the child, but not vice versa. What works: Inserting and deleting of the parent What breaks: Inserting a new child while updating the parent (child is not inserted) Code: Parent: Code: ... public class Folder { @OnDelete(action=OnDeleteAction.CASCADE) ...

33. OneToMany for class hierarchies bug?    forum.hibernate.org

Hibernate version:3.1.1 Class A has two extended Class A1 and Class A2, and they are mapped to a single table. Class B has OneToMany relationship both Class A1 and Class A2. When i get the collection of these in Class B object. the one have all the Class A object. and another is null. A.java Code: @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name ...

34. OneToMany/collection and discriminator problem    forum.hibernate.org

Hello! Hibernate version: 3.1.2, annotations: 3.1beta8, jdk: 1.5.0_06 It seems that delivering collections is broken while there must have been used a discriminator in single-table-per-hierarchy case. I wrote a little example showed the problem. Please help - whether it is a hibernate or mine problem. So, classes (I omit imports and getters-setters): @Entity @Table(name = "ITEMS_DRAW") public class ItemsDraw { @Id ...

35. Annotations: OneToMany - ManyToOne, FK is always 'null'    forum.hibernate.org

Hi to all, Hibernate version: 3.1.2 Hibernate annotations version: 3.1beta8 Name and version of the database: MySQL 5.0.19-nt i am new to hibernate and have some problems with the annotation for an OneToMany <--> ManyToOne mapping. The value of the foreign key field of the child records are always 'null' and do not carry the primary key of the parent record. ...

36. Hibernate query across OneToMany & ManyToOne    forum.hibernate.org

I've been trying to find an answer for my question here but I am not really sure what to search for. I've also read the HQL guide but didn't make my code work. I have three objects. First object (Document) has a OneToMany connection to an object CoAuthor (so a Set coAuthors is a field in Document). The Object CoAuthor is ...

37. Problem with oneToMany relations...    forum.hibernate.org

Hibernate version: 3.1 Hi people, Im having a problem with oneToMany associations... For example, The entity A have a list of entity B, when i insert a new element of B and update A everything goes clear... when i update a element of the list B and update A everything goes clear... but when i delete a element of the list ...

38. 3.2.0.CR1 Problem: @OneToMany -> @Embeddable    forum.hibernate.org

39. primary key in OneToMany List association    forum.hibernate.org

40. @OneToMany with @IndexColumn. Bug in deleting from the List    forum.hibernate.org

There is a very bad bug with deleting from an ordered @OneToMany List. I have the following: Code: @OneToMany(fetch=FetchType.EAGER) @Cascade(value={CascadeType.ALL, CascadeType.DELETE_ORPHAN}) @IndexColumn(name="submenuIndex") public List

getSubMenus() { if (subMenus == null) subMenus ...

41. Bad SQL gen'd with InheritanceType.JOINED and OneToMany    forum.hibernate.org

Pretty sure this is a bug...I have a class Report which extends Product with InheritanceType.JOINED and Product has a OneToMany of categories. Any time I try to query based on the categories I get the following exception. Thanks Query query = session().createQuery( "SELECT p.report FROM " + ReportPurchase.class.getName() + " p " + "WHERE p.report.categories IN (:categories) "); query.setParameterList("categories", categories); public ...

42. JPA OneToMany require a mid-table?    forum.hibernate.org

Hi, i'm using Hibernate 3.2 rc2 and hibernate annotation. When i'm using a OneToMany relationship with class A, B, i found it is strange that hibernate-tools generate tables: A, B and A_B! however, i don't think table A_B is neccessary when using OneToMany. so i only create table A and B, and this causes runtime exception: Hibernate operation: could not initialize ...

43. OneToMany sub objects filtering.    forum.hibernate.org

Can I only use method described in '15.4. Associations'? Maybe there is another better way to handle this? So I can get my objects with filtered sub objects without any maps, etc. I have: A1{b1, b2} A2{b3, b4, b5} I want to get somethink like this: A1{b1} A2{b3} Using method described in 15.4 I have: A1{b1,b2} b1 A2{b3,b4,b5} b3 :(

44. List ordering with @OneToMany    forum.hibernate.org

The EJB3 specification describes how to map an ordered list (ie a list ordered at load time) using @javax.persistence.OrderBy annotation: this annotation takes into parameter a list of comma separated (target entity) properties to order the collection by (eg firstname asc, age desc), if the string is empty, the collection will be ordered by id.

45. Mapping an OneToMany ANY mapping    forum.hibernate.org

Hi, I know this is not something normally done in hibernate but can you do a OneToMany mapping for an ANY relationship. We want to do this because we would like a join table for an Entity and all its ancestors: e.g. on the Join Table we would like the following fields: entityId, ancestorId, discriminator so for a given entity, it ...

46. @OneToMany not working correctly ????    forum.hibernate.org

Newbie Joined: Thu Mar 30, 2006 9:21 pm Posts: 11 Hibernate version: 3.2 GA Annotations 3.2 GA Name and version of the database you are using: Postgres 8.1 I cannot get hibernate to work with the collection I want to setup. Basically the problem is that the @OneToMany is (instead of deleting records from the many side of the relationship) trying ...

47. @OneToMany(cascade=ALL) does cascade but join table is blank    forum.hibernate.org

hi I have a strange problem I haven't been able to figure out. This doesn't happen from my web app, but happens when I write a mock test which should behave the exact same way. I'm stumped I have a very simple unidirectional one-to-many relationship w/ join table, Code: // this is the parent class, has a list of items @Entity ...

48. OneToMany not being lazy while iterating    forum.hibernate.org

Newbie Joined: Mon Oct 24, 2005 6:34 pm Posts: 14 Location: Guadalajara, Jalisco. Mxico. Hi there !! Shouldn't hibernate fill collections lazily with proxies ? then perform n selects while iterating ? When I iterate thorugh items in the collections, hibernate first hidrates all objects non lazily !! Here's a small example of my problem: Beans: Most of my beans have ...

49. @OneToMany with a String    forum.hibernate.org

50. Use of @OneToMany or @ManyToMany targeting an unmapped class    forum.hibernate.org

Hibernate version: 3.2.1 GA I have two classes like such: Code: @Entity @Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public class Category implements TanEntity, Imageable { ... @Id private String id; @Version private Long version = null; .... .... @CollectionOfElements ...

52. Mapping different classes oneToMany to one class.Help please    forum.hibernate.org

Hi! How do I have to map the following configuration without superclass for : ClassA with as field List ClassB with as field List in database : +--------------+----------+ | objectA_id | ... | +--------------+----------+ | 1 | ... | | 2 | | +--------------+----------+ +--------------+----------+ | objectB_id | ... | +--------------+----------+ | 1 | ... | +--------------+----------+ +--------------+----------+----------+----------+ | objectC_id | ...

53. @IdClass, composite key and @OneToMany relationship problem    forum.hibernate.org

I am having a problem trying to use an Entity as a part of composite PK. I am using separate class for @Embeddable PK and my example is similar to Footballer FootballerPk example. I am trying to have Country as a part of PK. I am getting: Caused by: org.hibernate.exception.ConstraintViolationException: could not insert: [com.alarm.indicators.Indicator] Hibernate trace is saying: Hibernate: insert ...

54. Another @IdClass, composite key and @OneToMany problem!    forum.hibernate.org

Newbie Joined: Fri Mar 02, 2007 10:34 pm Posts: 6 I posted this to the EJB3/JPA forum too, but I'm going to post it here too in hopes that it might get spotted more easily. Apologies. Like another recent poster, I am trying to set up what seems like a very simple one-to-many relationship, but having no luck. When I try ...

55. Database Constraints on OneToMany    forum.hibernate.org

* After previewing this post 3-4 times and finally submitting it I realized that this is exactly how a OneToMany ought to behave. The obvious solution is to change this to a ManyToMany relation. Thanks, my mistake. Moderators plz delete. Hello everyone, I'm having some sort of schema generation or MySQL constraint issue. I have the following Project mapping: Code: ...

56. OneToMany in combination with MappedSuperclass    forum.hibernate.org

I'm trying to setup a model that separates from-the-database-generated code from user editable code, in order to minimize coding efforts. In order to do so, each entry has two classes, where one inherits the other. The generated class is being inherited, e.g.: @MappedSuperclass public class Article ... While the editable class only refers to the table: @Entity @Table(name="article") public class Article ...

57. Inheritance with multiple OneToMany collections    forum.hibernate.org

I'm having a problem with a class that has multiple collections of the same base type. I think the problem is that it's not applying the discriminator in the WHERE clause. Collections: @OneToMany(cascade = CascadeType.ALL, mappedBy = "document", fetch = FetchType.EAGER) public List getSigners() { return signers; } @OneToMany(cascade = CascadeType.ALL, mappedBy="document") public List getObservers() { if(observers == null) observers = ...

58. Override mappedBy onetomany annotation from mappedsuperclass    forum.hibernate.org

Hi everybody I have implemented an abstract MappedSuperclass that defines a OneToMany property. I want in subclases to override the "mappedBy" attribute of the OneToMany annotation, so Code: @MappedSuperclass public abstract class BasePersistentObjectTranslateable extends BasePersistentObject { @OneToMany() protected List translations; ...

59. Seam, OneToMany & Composite Key    forum.hibernate.org

Author Message cparham Post subject: Seam, OneToMany & Composite Key Posted: Mon Apr 30, 2007 9:06 pm Newbie Joined: Wed Mar 07, 2007 11:27 pm Posts: 3 Hello: i'm trying to put together a working Seam example showing a OneToMany relationship using a composite primary key. Something like Order & LineItems from the Java EE 5 tutorial. My attempts ...

60. OneToMany fetch optimization    forum.hibernate.org

Hi, I have a OneToMany relation between Foo and Bar. class Foo { @OneToMany(FetchType=Eager) Set bars; } The db mapping uses an extra join table. When I do a "select * from Foo", I get for each row in Foo a join-select on bar and the join table. Is it possible to optimize it in a way, that only a single ...

61. [solved] @ManyToOne and @OneToMany; index position of list ?    forum.hibernate.org

Hibernate 3.2.3, Hibernate Annotations 3.3.0 This subject has shown up MANY MANY times in this forum and throughout the documentations. I am sorry to bring it up again, but even though I was reading many hours through the documentation/forum, I have not *understood* WHY we need to model this relationship in certain ways. I hope for EXPLANATIONS rather than a simple ...

62. model ManyToMany as 2 OneToMany validation sought.    forum.hibernate.org

Newbie Joined: Mon Nov 03, 2003 1:07 am Posts: 14 I have the a Role and a Permission object that I modeled with a ManyToMany relationship (role.getPermissions() and permission.getRoles()) The problem I encountered with this bi-directional ManyToMany was that I could only have changes made to one end be persistent, where I wanted to be able to manage this relationship from ...

63. @Filter not working for @OneToMany association    forum.hibernate.org

Hi folks, I have defined this filter class Product { .... @OneToMany(mappedBy="target", cascade=CascadeType.ALL) @Filter(name="productReviewFilter", condition="filtered = false") private List reviews = new ArrayList(); .... } but one trying to enable it for the session, I get: session.enableFilter("productReviewFilter"); Exception in thread "main" org.hibernate.HibernateException: No such filter configured [productReviewFilter] Am I missing something? TIA Cheers, Carlos

64. Swapping elements in OneToMany list    forum.hibernate.org

Hello, I'm unable to swap elements of unidirectional list supported with additional database table. Model Code: @Entity public class Unit { private Long id; private List actions = new LinkedList(); @Id @GeneratedValue public Long ...

65. bidirectional OneToMany throws LazyInitializationException    forum.hibernate.org

Hi all, I've a specific problem with my EJB3 Hibernate code (using Seam, but I don't think this has anything to do with it). This is my case: I have a superclass entity bean: DefaultAccessControlList Code: @Entity @Table(name="access_control_list") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn( name="type", discriminatorType=DiscriminatorType.STRING ) @DiscriminatorValue("default") public class DefaultAccessControlList implements Serializable { ...

66. Is @OneToMany unidirectional is a good design?    forum.hibernate.org

A few days ago in another forum somone told me that @OneToMany unidirectional is not a good design. As i see it from the point of view of java developer and not from the DB side this is more compatible with Java, because in the class diagram you will see that class A has list. In the DB there are a ...

67. EJB 3 OneToMany with Composite Key    forum.hibernate.org

Newbie Joined: Wed Jul 04, 2007 9:06 am Posts: 12 Hi all, Having a problem setting up my first EJB 3 OneToMany relationship with a composite key. Here's the error: 14:09:01,812 WARN [JDBCExceptionReporter] SQL Error: 957, SQLState: 42000 14:09:01,812 ERROR [JDBCExceptionReporter] ORA-00957: duplicate column name The 'One' Entity: Code: Code: import javax.persistence.*; import java.io.Serializable; import java.util.Collection; @Entity @Table(name = "COMMS_MESSAGES") public ...

68. How to add exisitng object to OneToMany    forum.hibernate.org

But, If you send detach Room to transaction B and add it to the collection you will get an exception. Hibernate think that it need to call to persist (i dont understand why). If you will call explitity to mere on the collection it will be ok. If you will put cascade mere on collection it will work. If you put ...

69. What is preffered OneToMany with association table or Join    forum.hibernate.org

The default is association. And i know that if you have association with bag than it will delete and insert again in case that you add new Object to the collection, so it is a bad performance. But, i thnik the advatage in association is that you can add exisitng Object to the collection. So, what do you think? Thank you ...

70. OneToMany Problems with Delete, Merge the Childs    forum.hibernate.org

Hibernate version: 3.2 Mapping documents: Annotations Name and version of the database you are using: MySQL 5.0 Hi, I have some problem with a OneToMany Relation. I have a class called "Event" which has many "Action" objects. The Action objects were saved in an ArrayList inside the Event. The first time I started the program, everything is right all table were ...

71. Issues with @OneToMany Bidirectional relationships    forum.hibernate.org

@Entity public class Troop { @OneToMany(mappedBy="troop") public Set getSoldiers() { ... } @Entity public class Soldier { @ManyToOne @JoinColumn(name="troop_fk") public Troop getTroop() { ... }

72. Delete operation not cascading on OneToMany relationship    forum.hibernate.org

Newbie Joined: Wed Mar 02, 2005 10:52 am Posts: 7 I am probably missing something here but here we go. I have 2 classes, User and Authority, mapped using annotations. A User has a List of authorities(OneToMany relationship). The thing is, when I remove a item from the list(say, using ListIterator) and issue session.update(user), the delete is not cascaded. It tries ...

73. annotations: bidirectional OneToMany fk    forum.hibernate.org

have simple pojos Code: public class A { protected int aId; private List bs = new ArrayList(); @Id @GeneratedValue @Column(name="a_id") public int getAId() { return aId; } ...

74. Does hibernate mark every record in OneToMany Set as dirty?    forum.hibernate.org

Newbie Joined: Mon Nov 03, 2003 1:07 am Posts: 14 Hi, When I save my "site" object, hibernate issues an update statement for each of my items in my OneToMany Set. There is a OneToMany relationship between site and siteattraction. All I do to trigger these updates is to initialize the set and print out how many there are in the ...

75. orphan child records not deleting in @OneToMany association    forum.hibernate.org

Hello - I've got a one-to-many relationship between A and B. For each A, there can be 0 or many Bs. When I add a new B to the list, then call entityManager.merge(A), it works fine. The new B is also persisted in its own table. However, if I manipulate the list of Bs by removing a couple of the B ...

76. orphan child records not deleting in @OneToMany association    forum.hibernate.org

Hello - I've got a one-to-many relationship between A and B. For each A, there can be 0 or many Bs. When I add a new B to the list, then call entityManager.merge(A), it works fine. The new B is also persisted in its own table. However, if I manipulate the list of Bs by removing a couple of the B ...

77. Help set oneToMany bidirectional relationship.    forum.hibernate.org

Hi all I need help setting oneToMany bidirectional relationship. My entities are CUSTOMER and ORDER, each customer have several orders, From each order I would like to be able to get the customer. I get this exception on build: AnnotationException: mappedBy reference an unknown target entity property: com.company.model.OrderEntity.customerEntity in com.company.model.CustomerEntity.OrderEntity Please advise Sharon Customer Entity: Code: @Entity @Table(name = "CustomerEntity") public ...

78. Using Discriminator for OneToMany annotation    forum.hibernate.org

Though I feel it is really unfair on your part to expect a solution/ reply without providing any significant information (mapping, class structure, etc.) yet... You can add a where clause in set that would restrict the elements in set. something like

79. Doubt on OneToMany mapping    forum.hibernate.org

Author Message anand82_r Post subject: Doubt on OneToMany mapping Posted: Fri Nov 09, 2007 11:30 am Newbie Joined: Mon Nov 05, 2007 11:57 pm Posts: 2 Hi, I have two entities, Parent and Child. The Parent has a collection of Child entities (a OneToMany relationship). The Child in-turn has a collection of Child entities (a OneToMany relationship with itself). ...

80. Query on Entity With OneToMany relation by JoinTable mapping    forum.hibernate.org

@Entity public class Shelf { public int shelfID; public List books; @Id @GeneratedValue(strategy= GenerationType.AUTO) public int getShelfID() { return shelfID; } ...

81. OneToMany - parent column not PK    forum.hibernate.org

@OneToMany(targetEntity = SoftGenre.class, fetch=FetchType.LAZY) @LazyCollection(LazyCollectionOption.EXTRA) @JoinTable(name = "PROGRAMME_FEATURE", joinColumns = { @JoinColumn(name = "PROGRAMMEID", referencedColumnName="PROGRAMME_ID", unique=false, nullable=false, insertable=false,updatable=false ) }, inverseJoinColumns = { @JoinColumn(name = "WORD", referencedColumnName="SOFTGENREID", unique=false, nullable=false, insertable=false,updatable=false) })

83. @OneToMany/@ManyToMany declared as Collection of Interface    forum.hibernate.org

Following is the intent 1. // declare a relationship to a Interafce public class X { @ManyToMany Collection interfaces; } public interface SomeInteface { String getName(); } 2. During runtime, populate the collection with persistence instances that implement SomeInterface I understand that JPA spec is silent about interface. What is Hibernate's way of supporting the above in JPA environment?

84. OneToMany instead of ManyToMany    forum.hibernate.org

If i am right, i think the problem may be with the data you are trying to insert. You may need to check with your code in other parts that whether the value is getting passed correctly or not. Because you will get "not null property references.." error while trying to insert a null value into the database column which is ...

85. OneToMany Relationship does not work    forum.hibernate.org

public class Band { @OneToMany (cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)//(mappedBy="artist") @LazyCollection(LazyCollectionOption.FALSE) @JoinColumn (name="memberId") @org.hibernate.annotations.IndexColumn(name = "musicianId") private List members = null; } public class BandMember { @ManyToOne ...

86. @OneToMany targeting an unmapped class    forum.hibernate.org

Hi, I have a class @Entity @Table(name="edges") public class Edge implements Serializable { static final long serialVersionUID = 1234567; @Id @GenericGenerator(name = "gen", strategy = "uuid") @GeneratedValue(generator = "gen") private String id; private int priority; private boolean stop; @OneToMany(mappedBy="edges") private List lanes; [...] } and another class @Entity @Table(name="lanes") public class Lane implements Serializable { [...] } However I receive an ...

87. OneToMany bidirectional: saving new objects together    forum.hibernate.org

Newbie Joined: Mon Dec 24, 2007 11:03 am Posts: 3 Hibernate version: 3.2.5.ga Hibernate Annotations version: 3.3.0.ga MySql 5 / PostgreSQL 8.1 Many times I tried using Hibernate for my small projects, but I always gave up at the first collection mapping problem. Now I can afford some debug time, so I put together a small example demonstrating my newbie problems. ...

88. ManyToOne and OneToMany    forum.hibernate.org

Hi, I have two entities: Province and City. City has a Province many-to-one field and Province has a one-to-many set of Cities. When I create a new City, and associate it with a Province, the set of cities in the associated Province instance does not get updated within the current session. It doesn't bother me much in a web app, because ...

89. OneToMany EJB3 FetchType.LAZY is ignored    forum.hibernate.org

Hi i have class Account containing a list of class Tracks: ------------------- class Account { private List tracks; @OneToMany(mappedBy = "account", fetch = FetchType.LAZY, cascade = CascadeType.ALL) @OrderBy("trackName ASC") @OnDelete(action=OnDeleteAction.CASCADE) @Basic(fetch = FetchType.LAZY) @LazyToOne(LazyToOneOption.PROXY) @LazyCollection(LazyCollectionOption.TRUE) public List getTracks() { return this.tracks; } } ------------------- a query of type ------------------- em.createQuery("from Account u where u.loginName = :loginName"). setParameter("loginName", loginName).getSingleResult(); ------------------- directly loads ...

90. Heavy perfomance degradation when adding child to @OneToMany    forum.hibernate.org

Hi i have a parent class Track which contains some thousands child instances of type Location: ------------------------ class Track { ... @OneToMany(mappedBy = "track", fetch = FetchType.LAZY, cascade = CascadeType.ALL) @OrderBy("timestamp ASC") @OnDelete(action=OnDeleteAction.CASCADE) public List getLocations() { return locations; } } ------------------------ When i insert a new Location instance: ------------------------ track.addLocation(location); em.persist(location); return location.getLocationId(); ------------------------ the EntityManager triggers thousands of selects ...

91. OneToMany bidirectional insert problem    forum.hibernate.org

Hi All, I have a problem with a parent-children relationship. I try to add an Event element on the many side but this isn't saved on db. this is my code: Event evento=new Event(); ... //Load the account from DB Account account = accountManager.getAccount(1); account.addEvent(evento); //saveAccount() method execute the saveOrUpdate() using Spring HibernateDaoSupport accountManager.saveAccount(account); Hibernate version: 3.2.3.ga Mapping documents: @Entity @Table(name="ev_accounts") ...

92. Question on OneToMany relation with Map (weired behaviour)    forum.hibernate.org

Hi, I think you need to use CascadeType.DELETE_ORPHAN in addition to CascadeType.ALL (the org.hibernate.annotations version rather than javax.persistance). It's my understanding that hibernate will not assume that an entity can be safely deleted when it's removed from a collection, as it doesn't know if the entity is being used elsewhere (entities have their own independant lifecycle). DELETE_ORPHAN is the way of ...

93. onetomany mapping problem    forum.hibernate.org

Hi everyone i will make the question straight: how can i make a OneToMany bidirectional mapping without this excepcion: Code: Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: org.cnio.appform.entity.User.interviews[org.cnio.appform.entity.Interview] at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1033) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:576) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:517) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1136) ...

95. ConstraintViolationException using @OneToMany and @JoinTable    forum.hibernate.org

Newbie Joined: Thu Mar 20, 2008 12:57 pm Posts: 1 Hibernate version:3 MySQL 5 JBoss 4 MyEclipse I have searched these forums and the web related to this exception and not been able to figure out the issue in my case: ERROR [AbstractFlushingEventListener] Could not synchronize database state with session org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update I am using Java, ...

96. Bidirection OneToMany stopped working    forum.hibernate.org

Got a strange situation here. At some point after we turned on the second level cache and query cache for our project, all the bidirectional one-to-many associations stopped working in the application. The ids are still there in the DB but the caollection on the one-to-many side for about 6 different collections in 4 classes has stopped being retrieved from the ...

97. Unidirectional onetomany    forum.hibernate.org

98. Simulating Bidirectional OneToMany from SQL to Hibernate?    forum.hibernate.org

Hello, I'm working with a project that is making use of storedprocs. and has been switching to Hibernate. I have a table that row entries are created by the stored proc and would like to be able to have a jointable and that would be used to reference multiple corresponding Hibernate Mappings. I would also like to have the corresponding object ...

99. onetomany unique contraint    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp hi! i try to map a locationtype to a location! but if i add a location holding the same locationtype-foreignkey in the table i get an exception! i tried to set the attribute unique=false at the joincolumn annotation but this didn't work! help please... @Entity public class Location { @OneToOne @JoinColumn(name="locationType_fk") ...

100. onetomany unique contraint    forum.hibernate.org

hi! i try to map a locationtype to a location! but if i add a location holding the same locationtype-foreignkey in the table i get an exception! i tried to set the attribute unique=false at the joincolumn annotation but this didn't work! help please... Code: @Entity public class Location { @OneToOne ...