OneToMany 3 « Map « JPA Q&A





1. JPA OneToMany relations and performace    stackoverflow.com

I have two entities: parent Customer and child Order.
Each Customer has 1,000,000 Orders for example, so it is not needed in any given time to load a Customer with all Orders ...

2. JPA Bidirectional OneToMany and ManyToOne?    stackoverflow.com

I'm using Oracle JDeveloper 11g Release 2. I created two tables A and B using SQL developer. Table A has a FK to table B. Using the Entities from Tables function, I ...

3. Inverse @OneToMany non updatable    stackoverflow.com

Having the following entity:

@Entity
class Transaction implements Serializable {

  @Id @GeneratedValue
  Long id

  @Column(nullable = false, updatable = false)
  Long trNumber

  @OneToMany(mappedBy = "transaction", cascade = CascadeType.ALL, ...

4. CRUD with a OneToMany association under Struts 2 / Hibernate 3    struts.1045723.n5.nabble.com

Struts - User - CRUD with a OneToMany association under Struts 2 / Hibernate 3 Struts Struts - User CRUD with a OneToMany association under Struts 2 / Hibernate 3 Classic List Threaded Locked 18 messages bruno grandjean-2 Reply | Threaded Open this post in threaded view | Report Content as Inappropriate ...

5. JPA bidirectional OneToMany Problem    coderanch.com

I have two entity classes with a bidirectional relationship thus: class Supervisor { @OneToMany private Collection projects; } class Project { @ManyToOne private Supervisor supervisor; } Here is my test case: public testCreateProject() throws Exception { EntityManagerFactory emf = Persistence.createEntityManager("PU"); /* Retrieve the current list of projects */ EntityManager em = emf.createEntityManager(); Supervisor s = (Supervisor) em.find(Supervisor.class, 1); int beforeSize = ...

6. @OneToMany Hibernate 3 @Filters not working    coderanch.com

Hi All, Thanks in advance to any pointers and info. I have a DB schema design which uses Soft/virtual Deletes where every table has a column del_ind(number) which indicates(1/0) whether a row is considered deleted or not. If the app wants a row to be deleted, it then sets it to 1. On normal insertion, this column is set to 0. ...

7. Beginner needs help with @OneToMany relationship (jpa)    coderanch.com

Hello, I have a "Statement" class that holds a collection of "Amount" classes as follows: This is part of the Statement class: @OneToMany(cascade = CascadeType.ALL, mappedBy = "statement") private Collection amountCollection; The Amount class has a pk made up of several fields as follows: public class AmountPK implements Serializable { @Column(name = "AMOUNT_CATEGORY_CODE", nullable = false) private String amountCategoryCode; @Column(name = ...

8. testing jpa - OneToMany    coderanch.com

I'm trying out some basic stuff with EJB3/JPA. Using glassfish V2 and first Toplink then Hibernate (does seem to work better). I've made what I think is the most basic example possible, but somehow it doesn't work: I'll post the code here, only the relevant bits: I have a Medic entity: @Entity public class Medic implements Serializable{ .... @Id @GeneratedValue public ...





10. [JPA - Hibernate] OneToMany without join table    coderanch.com

I have 2 Objects for this question. Color.java --id --name --description --@OneToMany private List attributes; ProductAttributes.java --id --Color color JPA is generating the Color and ProductAttributes tables but also it is creating a Color_ProductAttributes table. This table doesn't really need to be there, I don't think. So questions: 1. How to set up the annotations so that this table is not ...

11. Couldn't persist OneToMany JoinColumn/JoinTable (Unidir) using TopLink JPA    coderanch.com

Zipcode class @Entity @Table(name="ZIPCODE") public class Zipcode implements Serializable { @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER) @JoinColumn(name="ZIPCODE_ID") or @JoinTable(name="ZIPCODE_ZIPNAME", joinColumns={@JoinColumn(name="ZIPCODE_ID")}, inverseJoinColumns={@JoinColumn(name="ZIPNAME_ID")}) private Collection zipnames = new ArrayList(); public Collection getNames() { return zipnames; } public void setZipnames(Collection zipnames) { this.zipnames = zipnames; } ..... Zipname class does not maintain relationship back to Zipcode. public class ZipcodeApplicationClient { @PersistenceContext(unitName="GeographicalDB-PU") private static EntityManager manager; public ZipcodeApplicationClient() { ...

12. Excepion: mapping cannot have columns in this context(JPA/OpenJPA OneToMany using single table)    coderanch.com

I want use JPA(provider:OpenJPA) to implement the funciton of category without level limit, and just using one table like the following, and use the annotation: [b ]@OneToMany(fetch=FetchType.LAZY) @JoinColumn(name="pid")[/b] But there alaway exception when using "org.apache.openjpa.jdbc.meta.MappingTool" to generate schema or access data after created schema manually. If I remove the two line of @OneToMany and @JoinColumn, things go well. +-------+--------------+------+-----+---------+-------+ | Field ...

13. IN clause filtering on OneToMany/ManyToMany associations in JPQL    coderanch.com

Hi there, I'd like to ask for an advice with a problem regarding OneToMany/ManyToMany mappings. Basically, what I'd like to do is to create named query like this: "SELECT ch FROM channel ch WHERE ch.channelTypes IN (:typeList)" where :typeList parameter is collection of desired ChannelType instances (or Integers, if necessary). channelTypes field in Channel entity is ManyToMany mapping defined as following: ...

14. Hibernate - Problems with @onetomany    coderanch.com

2.2.5.3.2.1. Bidirectional Since many to one are (almost) always the owner side of a bidirectional relationship in the EJB3 spec, the one to many association is annotated by @OneToMany( mappedBy=... ) @Entity public class Troop { @OneToMany(mappedBy="troop") public Set getSoldiers() { ... } @Entity public class Soldier { @ManyToOne @JoinColumn(name="troop_fk") public Troop getTroop() { ... }

15. Basic JPA @OneToMany / @ManyToOne mapping trouble (related to hibernate?)    coderanch.com

I am using JPA in a J2SE application ("resource-local"), and I'm facing a basic problem which is strikingly little discussed on the web. Given the following entities (a Project consists of a list of Employees): @Entity public class Project { @Id @Column(name="PROJECT_ID", nullable = false) private long id; @OneToMany(mappedBy="project", cascade = CascadeType.ALL) private List employees; Project() { } public List getEmployees() ...

16. Problem with onetomany relantionship with JPA    coderanch.com

Hello everybody, i have a problem with a onetomany relationship, i put my classes and the log with the error, import java.math.*; import java.sql.*; import java.util.*; import java.util.Date; import javax.persistence.*; import org.openxava.annotations.*; import org.openxava.gestion.utilidades.*; import org.openxava.util.*; /** * Elementostvpaga entity. * * @author MyEclipse Persistence Tools */ @Entity @Tab(properties="productostelecom.organizaciones.nombre, productostelecom.nombrePlan, productostelecom.rentaMensual") @View( // 2 members= "productostelecom; "+ "Datos Grales [#rentaMensual, costoContratacion; ...





17. Problem with onetomany relantionship with JPA 2.0    coderanch.com

Hello everybody, i have a problem with a onetomany relationship, i have a elementostvpaga that can have many canales and a canales class tha can have many elementostvpaga, when in mi view i tried to visualize it i get an error i put my classes and the log with the error, thks. @Entity public class Elementostvpaga implements java.io.Serializable { // Fields ...

18. Conditional FetchTypes in Hibernate OneToMany Mappings.    coderanch.com

Right up front... This is a NON-URGENT question! (I'm just trying to broaden my knowledge past where Cameron has got me ) Having just finished "Hibernate Made Easy" (McKenzie) I've been trying to expound the benefits of ORM to a highly experienced DBA at work. After explaining the Team-has-Players example (OneToMany annotation), and delving deeper in to the FetchType = LAZY ...

19. How to represent JPA @OneToMany for Two Many Tables?    coderanch.com

If you have a "1" table that is 1:M with two tables, how do you represent that in JPA @OneToMany Annotation? If I try to have two @OneToMany annotations in my "1" side Java class, I get an duplicate annotation error. So, what I'm asking is that if you have some type of, say, "ID" (from the 1 table) that can ...

20. JPA - understanding OneToMany bidirectional relations    coderanch.com

Hi, I think I don't understand very well how the OneToMany bidirectional relations work in JPA. In the database I have the following tables/records Professor(ID INTEGER,DEPARTMENT_ID INTEGER) Select * from Professor ID |DEPARTMENT_ID ----------------------- 1 |1 Department(ID INTEGER) Select * from Department ID --- 1 My Entities are: @Entity public class Department { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private int id; @OneToMany(mappedBy="department") private Collection ...

22. JPA with onetomany between two tables, each having compound primary keys    coderanch.com

Can someone please provide a working example of how to map with JPA, the following situation. One to many between two tables each having compound primary keys as follows: We have searched everywhere and cannot find any examples using compound keys in both tables. Here is what I have thus far. create table SUPPLIER_STUPID ( SUPPLIER_PART_1_ID_PK1 VARCHAR2(15) NOT NULL, SUPPLIER_PART_2_ID_PK2 VARCHAR2(15) ...

23. Error book Hibernate Recipes a problemsolution approach(@OneToMany bidirectional Using a Join Table)    coderanch.com

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in class path resource [META-INF/spring/spring-master.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [META-INF/spring/spring-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Associations marked as mappedBy must not define database mappings like @JoinTable or @JoinColumn:

24. JPA @OneToMany filters    java.net

Hi everybody, I've seen JPA gives options with @OneToMany in order to limit the retrieved elements with those available in another table, using @JoinTable annotation. I'd like to know if one can limit the retrieved list to elements having a specific column set to NULL. Actually, I'm using this kind of column in order say when the row has been disabled ...

25. Noob JPA question OneToMany and what actually gets pulled from DB and when?    java.net

In the prototype of the app we just used SQL/JDBC and some of the queries were really complex with a lot of joins across multiple tables and it did work OK. However, I like the idea of using @OneToMany and similar annotations in JPA to define relationships between entities as it would be great for example, given an instance of an ...

27. JPA: Delete children in OneToMany    java.net

I have a new problem with a cascading delete in a unidirectional onetomany relation. I have two enteties, A and B. One instance of A can have several instances of B in a Collection. The two enteties are joined with a join table that have two columns, the PK from the table of A and B. B is not aware of ...

30. carthesian product in OneToMany relation    forum.hibernate.org

@Entity public class A implements IofA { @Id private Long key1; privtae Long searchValue; @OneToMany(mappedBy = "key1", fetch = FetchType.EAGER) private List finance; // further members, getter and setter ...

31. @OneToMany Annotation help    forum.hibernate.org

Hi I have an Applicant class and an Applicant_Minority class The former has subjectId as the primary key and the latter has subjectId and minorityProgram as the embedded Primary key. I would like to form a OneToMany relationship between the two, and it will be unidirectional. getAppliantMinorityPrograms(){ } setApplicantMinorityPrograms(ApplicantMinorityPrograms applicantMinorityPrograms) { } Please let me know how to form the OneToMany ...

32. is there a way to have customer query on a oneToMany?    forum.hibernate.org

I have this weird legacy schema where there is a Users table with a userid field(PK) and an objId field(not PK) and other fields. Then there is this Account table. Between them, there is a UserAcct table with a useracct2users field. Well, the objId and the useracct2users are used to join the useracct and user table(yes, quite weird). I would like ...

33. Unidirection OneToMany, IndexColumn duplicate entry error    forum.hibernate.org

Hi, I am using Hibernate 3.3.2 with Annotations 3.4.0 and MySql 5.1. With the following mapping: Code: @OneToMany(fetch = FetchType.EAGER) @JoinTable(name = "user_profile_photo", joinColumns = {@JoinColumn(name = "user_profile_id")}, inverseJoinColumns = {@JoinColumn(name = "photo_id")}) @IndexColumn(name = "ordinal") ...

34. OneToMany, IndexColumn and so on..    forum.hibernate.org

Hello All :) I am new to Hibernate, but I am SQL profi since DB2 7.2 in the jear 2000. My Target is to patch Hyperhaxb3 generated sources for Hybernate 3.3.2 to providing @IndexColumn for 1-N handling using Hibernate 3.4 annotations.. There is a requirement that no extra/not-needed N-M AssoziationTables should be created. I have Understand IndexColumn and configured right, I ...

35. @OneToMany mapping issue on UPDATE    forum.hibernate.org

I get the following error when I do an update.. 16:00:58,629 DEBUG [JDBCExceptionReporter] Could not execute JDBC batch update [update PAY set OPERATOR_DT=?, OPERATOR_ID=?, ACCOUNT_ID=?, AMOUNT=?, BATCH_ID=?, NOTE=?, CREATE_DT=?, INST_ID=?, IDNAME=?, STATEMENT_ID=?, STATUS_ID=?, EVENT_ID=?, EVENT_DT=?, PATIENT_ID=?, PLAN_ID=?, SCHEDULE_ID=?, STUDY_NUM=? where PAYMENT_ID=?] java.sql.BatchUpdateException: ORA-01407: cannot update ("MY_SCHEMA"."PAY"."EVENT_DT") to NULL at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343) at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10768) ------------------------------------------------------------------------ Classes >> @Entity @Table(name = "STATEMENT") public class ...

36. not-null constraint being violated in OneToMany    forum.hibernate.org

I have a join table schema relationship represented by OneToMany and ManyToOne associations and am having some trouble getting Hibernate to respect the not-null constraints on the foreign keys. The schema is similar to the following: TableA PKA Table AB (join table -- two columns as PK) (FK to Table A) <-- not-null (FK to Table B) ...

37. delete the child in a @OneToMany that has two parents    forum.hibernate.org

My entity classes are provided below. My 3 questions deal with deleting either the parent or child in a OneToMany relationship when the child also happens to have an additional 2nd parent that also holds a reference to it (See below for my entities with annotations and cascade rules) 1) If I run the following cascade rules would try to delete ...

38. OneToMany relationship not persisting properly    forum.hibernate.org

Newbie Joined: Sun Jan 03, 2010 9:34 am Posts: 2 I've got a problem with my mapping (I think) that is causing me no end of heartache. I have 2 classes, Section and Course that are mapped as so: Course: Code: @Entity public class Course implements Serializable, Comparable { @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column ...

39. OneToMany relationship, controlled by the parent, and not nu    forum.hibernate.org

What ever i try, i can't get it to work...please help. ...

40. Multiple OneToMany Set<> of the same entity    forum.hibernate.org

The answer is pretty simple, but it took me 2 days to find: Code: public class LineItem implements Serializable, XmlSerializable { private String id; // our primary key private String otherid; // our foreign key private Set firstSet; // onetomany linked with primary key private Set secondSet; // onetomany ...

41. OneToMany second level caching dehydratation behavior    forum.hibernate.org

Hi, I'm having a (I think) an unusual behavior of 2nd-level caching when a Set is annotated with @OneToMany. This is the case: Main entity, Hotel: Code: @Entity @Table(name = "HOTEL") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "all") public class Hotel extends AbstractPersistentObjectWithLogicalDeletion { ... @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "HOTEL_OID", ...

42. Problem with OneToMany annotation on delete    forum.hibernate.org

Hello I am having 2 classes : Code: public class Employee implements Serializable { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name = "EMPLOYEE_ID") private Integer id; @Column(name = "EMPLOYEE_REGISTRATION_NUMBER") private String registrationNumber; @OneToMany(targetEntity=EmployeeAccusation.class, cascade = CascadeType.ALL) ...

43. hibernate criteria OneToMany, ManyToOne and List    forum.hibernate.org

Hi, I have three entities ClassA, ClassB and ClassC. ClassA { ... @Id @GeneratedValue @Column(name = "a_id") private long id; ... @OneToMany(cascade={CascadeType.ALL}) @JoinColumn(name="a_id") private List bbb; ... } ClassB { ... @ManyToOne private ClassC ccc; ... } ClassC { ... private String name; ... } I want to filter by hibernate criteria ClassA by 'name' member of ClassC. So I want ...

44. @OneToMany Create problem    forum.hibernate.org

Hi, I'm getting the following exception during persistence when i have @OneToMany mapping in my hibernate objects. StackTrace Caused by: org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [insert into JOB_FREQUENCY_INFO (CREATED_BY, CREATED_ON, LAST_UPDATED_BY, LAST_UPDATED_ON, VERSION_NO, TYPE, VALUE, UUID) values (?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at ...

45. OneToMany for parentless objects.    forum.hibernate.org

I have a somewhat complicated schema where I want to do some magic to make a part of it more transparent. Basically I want something like this: Code: @Entity public class Enclosed { @ManyToOne private Container container; }; @Entity public class Container { @OneToMany(mappedBy="container") private ...

46. Bidirectional @OneToMany relation    forum.hibernate.org

Hi, I got stuck for a while with a java.lang.StackOverflowError exception and I haven't found a solution yet, so I decided to write on forum about it. Maybe someone else run into this problem and manage to solve it. I have two entities Invoice and Line. Line has a composite PK which contains Invoice PK's. Between Invoice and Line there is ...

47. Problem with hibernate + restrictions + OneToMany    forum.hibernate.org

public class DepartamentoTest extends TestCase { public void testDepartamentoSemTerceiro() { List dptos = new Departamento().listarPorAgencia(); for (Departamento departamento : dptos) { List cargos = departamento.getCargos(); ...

49. filter to filter @OneToMany    forum.hibernate.org

50. Restrict OneToMany Collection    forum.hibernate.org

Hi, I was wondering if it is possible to restrict a OneToMany relationship by a property on the destination table? i.e. instead of having a single relationship that I have to cycle through to pull out the values that I want, I would like to introduce 2 OneToMany relationships, one for each type of the destination class, so instead of getAllChildren() ...

51. CRUD with a OneToMany association under Struts 2 / Hibernate    forum.hibernate.org

Newbie Joined: Thu Mar 25, 2010 5:55 am Posts: 3 Hi I am trying to implement a simple CRUD with a OneToMany association under Struts 2 / Hibernate 3. I have two entities Parent and Child: @Entity @Table(name="PARENT") public class Parent { private Long id; private Set values = new HashSet(); .. @Entity @Table(name="CHILD") public class Child { private Long id; ...

52. PropertySelector OneToMany possible bug    forum.hibernate.org

Hi people, considering I have the following code: Entities: Code: @Entity @Inheritance(strategy=InheritanceType.JOINED) public class Pessoa { @Id @SequenceGenerator(name="pessoa_seq", sequenceName="PESSOA_SEQ", allocationSize=1) @GeneratedValue(strategy=GenerationType.AUTO, generator="pessoa_seq") private Long id; @OneToMany(mappedBy="pessoa", fetch=FetchType.EAGER, cascade=CascadeType.ALL) // At this time, I want Eager fetching ...

53. Issue with Multiple OnetoMany Relation    forum.hibernate.org

Newbie Joined: Fri Apr 09, 2010 1:59 am Posts: 1 I have three tables EmployeeEntity, LanguageEntity and SkillSetEntity EmployeeEntity has one to Many relationship with LanguageEntity EmployeeEntity has one to Many relationship with SkillSetEntity. When i use two OnetoMany relationship, i get the below error HibernateException: cannot simultaneously fetch multiple bags Code: @Entity @Inheritance(strategy = InheritanceType.JOINED) @Table(name = "EMP_INFO") public class ...

54. optional oneToMany association    forum.hibernate.org

Hi, I use Hibernate 3.4.0 and I create sql statement with Criteria API. There are two Entities - ResourceEntry and ActorAccessRecord. They have an optional oneToMany (1, 0...*) association. As FetchMode Join is selected. It runs into a problem, if the cardinality of ActorAccessRecord is "0". In this case, I got null result-set from query, because Code: "inner join T_ACTOR_ACCESS_LOGS actoracces2_ ...

56. @OneToMany strange issue    forum.hibernate.org

Hi, I have the following: Code: public class Family extends BaseObject { private Parent wife = new Parent(); private Parent husband = new Parent(); ... @ManyToOne(optional=true) @JoinColumn(name="wife_id", nullable=true) ...

57. Form to persist a @OneToMany relation    forum.hibernate.org

Beginner Joined: Sat Oct 03, 2009 1:51 pm Posts: 26 Hello! I have a form to persist a relationship one-to-many, I have a Contact class another Message class. A contact can have multiple messages and a message is just a touch. The tables are already created, my question is how is the form in JSP: Code:

...

58. JPA unidirectional @OneToMany without join table    forum.hibernate.org

59. Alternatives to filtering a OneToMany collection    forum.hibernate.org

Hi, I'm working on a Timesheet entry system where I have a header record with a "weekStarting" Date and child records with time for an individual date. I want to be able to retrieve the child records as part of a OneToMany relationship where the date of the child records is within the week defined by the weekStarting date on the ...

60. OneToMany with Composite and Foreign Key on Many side Delete    forum.hibernate.org

Newbie Joined: Fri May 14, 2010 4:34 pm Posts: 1 Hi, today I've encountered a really tricky issue (at least to me). I'm using hibernate-annotations 3.4.0.GA with hibernate-core 3.3.0.SP1. I am trying to model that kind of relationship: I have Artists and each of this Artist has TopTags. For various reasons I decided to model that as a one to many ...

61. @Loader on @OneTOMany doesn't work    forum.hibernate.org

Hi, I have the following problem. I use hibernate (3.5.1) mostly as a JPA implementation, but because I also use Derby with XML fields I need to also override the SQL's that hibernate is executing when working with Derby XML fields (basically to read / write from Derby XML fields I need to use XMLSERIALIZE and XMLPARSE). The override of the ...

62. @OneToMany causing wrong unique key?!    forum.hibernate.org

Hello *, I'm usually using JDO with DataNucleus, but for a customer's project, I'm porting some of our existing data models to JPA with Hibernate. Thus I'm pretty new to JPA and maybe I made a mistake in my usage of @OneToMany, but I'm pretty sure that I found a bug in Hibernate. Here's the situation (just a small & simplified ...

63. dynamic onetomany    forum.hibernate.org

Hello Friends, I have post my question on NHibernate forums and also posting it here just incase someone working with hibernate can help. I came across this link from Ayende with explains the adding the manytoone property at run time to an persistent class. "http://ayende.com/Blog/archive/2008/05/01/Dynamic-Mapping-with-NHibernate.aspx" I have a requirement in which I have to add a manytoone property to the children ...

64. How to create entity w/ generated pk & OneToMany relationshi    forum.hibernate.org

@Entity public class Entity2 implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId private Entity2PK pk = new Entity2PK(); //bi-directional many-to-one association to Cambios @ManyToOne @JoinColumn(name="entity1_id", insertable=false, updatable=false) private Entity1 entity1; ... }

65. [Newbie question] OneToMany problem    forum.hibernate.org

I would like to build up a test case about OneToMany bidirectional object relation. The modeled case is: people may have more phone number (phone * - > 1 person) (person 1 - > * phone) As for my understanding the foreign column (cperson_id) belongs to the cphone_number ...................................... CPerson.java @Entity public class CPerson { @Id @GeneratedValue private Long Id; private ...

66. Embedabble with a OneToMany relation is not working    forum.hibernate.org

Newbie Joined: Tue Jun 22, 2010 9:35 am Posts: 1 I have a Parent class mapped as an entity. Parent has a @ElementCollection on a Child class mapped as embeddable. The child class has a OneToMany on a AnotherEntity class mapped as entity. I'm using hibernate 3.5.1.Final (both for core and annotations) When I instanciate the session factory, I encounter a ...

67. OneToMany with inheritance    forum.hibernate.org

I would like to find a way to form a OneToMany relationship to objects that are retrieved from the child tables of an inheritance structure. For example I have a table, Shape, that represents the super class of the inheritance structure. In the java class for Shape it includes the annotation @Inheritance(strategy=InheritanceType.JOINED). I then have tables that represent the subclasses of ...

68. Formula for OneToMany assotiation    forum.hibernate.org

Hello, i'm new working with Hibernate and i would like to know if it is possible to 1. MAKE A REFERENCE OF A COLLECTION OF EMBEDDABLE ELEMENTS TO A DATABASE VIEW? 2. IF YES, HOW COULD I DO THIS? The View is calculated from the UNION of two SELECTS. The Relationship is made throw the atrribute key (see example) and not ...

69. Hibernate tries to delete oneToMany if not PersistentSet    forum.hibernate.org

Hi everybody, If I load an object with its children in eager mode, example Person with its adresses, I change my addresses collection, first it was a persistentSet then I put an HashSet. I do that because I don't keep my Hibernate objects throw my different layers, I translate them into other entities but keeping same data. So when I come ...

70. Delete +Update not working in OnetoMany Unidrectional    forum.hibernate.org

Newbie Joined: Mon Aug 02, 2010 7:56 am Posts: 2 This is my first post. I am trying s sample where I have onetomany relationship Code: CREATE TABLE stock ( STOCK_ID int(10) AUTO_INCREMENT NOT NULL, STOCK_CODE varchar(10) NOT NULL, STOCK_NAME varchar(20) ...

71. Bi-directinal OneToMany with EmbeddedId    forum.hibernate.org

I'm using Hibernate Entity Manager 3.3.2 and am trying to create a bi-directional OneToMany association with the OneToMany side being the owning side. My two tables are set up like so: Table 1 APPID primary key generated by a sequence on the database Table 2 APPID foreign key to Table 1 and part of primary key OFF_NO part of primary key ...

72. @OneToMany malfunction by only one side    forum.hibernate.org

73. OneToMany - unique java objects    forum.hibernate.org

I have an object that contains a list of options. The list of options is represented as a OneToMany relationship. Each Option then has a OneToMany relationship to values via a Join Table as below: Code: @OneToMany(fetch=FetchType.EAGER) @JoinTable(name="OptionValue", joinColumns = @JoinColumn(name="option_id", referencedColumnName="id"), ...

74. OneToMany Entity Association Problem , several columns keys    forum.hibernate.org

Hello there, sorry I am a beginner with Hibernate mapping system. 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,...] You have to understand that an Contact is linked to a User thanks to the ref, ...

75. OneToMany - BatchedTooManyRowsAffectedException    forum.hibernate.org

76. Problems with @OneToMany dual mapped.    forum.hibernate.org

77. Problem with removing children from a relationship OneToMany    forum.hibernate.org

Gentlemen, I have a question (Forgive me for bad english I'm Brazilian). I am using Hibernate and saving an object (Father) that has a Set <> another object (Son) Imagine the following situation: I made a saveUpdate of a father with three children. Saved perfectly! Then I made a saveUpdate that same Father, but with only two children. The third son ...

78. One shot delete on onetomany association    forum.hibernate.org

I have been trying to get one-shot delete working on my one-to-many association using only collection semantics but with no luck. Would be great if some one can provide pointers on this. Code: // The entities class Users{ ... public void setPhones(Set phones){ this.phones = phones; ...

79. A sense of style: @OneToMany or @ElementCollection?    forum.hibernate.org

Hello, everybody! In JPA 1.0 I could map the collection association to DocumentSubject (only accessible through the Document entity) like this: Code: @Entity @Table(name = "SUBJECTS") public class Subject { @Id @Column(name = "SUBJECT_ID") private int id; private String description; ...

80. Fetch multiple onetoMany relationships Hibernate JPA    forum.hibernate.org

Collection B bs = A.getBs(); for (final B b : bs) { b.getCs().getDs().size(); b.getEs().getDs().size(); b.getFs().getDs().size(); } ...

81. OneToMany mapping using Map. Problem with merge    forum.hibernate.org

Yes I wan't to use combination of donor and phone type as ids. That way there will be only one record for given donor and phone type. The donor can have multiple records, but they will differ in Phone Type. For example a donor will have a Mobile phone number, Office Phone number and residence phone number. Do you think this ...

82. @OneToMany between parent to child composite primary key    forum.hibernate.org

Hi, I have a one to many relationship between two classes PARENT and CHILD. The relationship is between the parent primary key (autogenerated oracle sequence when persisted) to one of the member of composite primary key of the child Parent Child ------- ------- parentId ------------>|parentId | ----> Composite primary key of child (parentId + child_dept_key) Name -|child_dept_key| -dept-name And my entity ...

83. OneToMany ON DELETE SET NULL    forum.hibernate.org

Hi, i have a quite huge project with a lot of OneToMany relations. The problem is that hibernate doesn't set the foreign key to NULL when i delete a parent entity. So a value remains in the database that doesn't exist anymore (producing errors in hibernate core). Is there any way to tell hibernate to set every foreign key to NULL ...

84. OneToMany association pron    forum.hibernate.org

public TP_Employee getEmployeeDetails(String gpn){ Session session = SessionUtil.getInstance(); try{ Transaction transaction = session.beginTransaction(); String queryString = "from TP_Employee where emplid = :emplid"; ...

85. Set columns to return in oneToMany    forum.hibernate.org

Hello my friends, i have a question about oneToMany annotation. I need receive a list of joined object with oneToMany annotation, and this is easy. But how can i do for receive just some column from the join table and not all?? cause there is one blob column that i don't need it, and this is heavy to have in any ...

86. OneToOne and OneToMany no join table    forum.hibernate.org

Is something like that going to work ???? Two classes mapped on two tables only - no join tables . OneToOne - bidirectional and ManyToOne unidirectional relationship Seminar can have multiple students ,seminar has one owner, user can be an owner of multiple seminars, user can take part in multiple seminars Is the mapping going to work @Entity public class Seminar ...

87. @oneToMany weird DDL generation    forum.hibernate.org

88. [SOLVED?]OneToMany relation that is also id in owner fails.    forum.hibernate.org

Newbie Joined: Fri Dec 10, 2010 4:55 am Posts: 2 I have 2 entities that are related through both a onetomany and a manytoone. The owning entity uses a composite primairy key that consists of the foreign key from the owned entity. If I remove the @Id in the owning entity (at getProfileType() in IProfileTypeImpl). Everyting seems to work (except for ...

89. JPA Hibernate: bidirectional relationship (OneToMany)    forum.hibernate.org

Hi everyone, I have to JPA Hibernate a 1-n relationship to the databank. The relationship consists of a "user ", the number of "addresses" has. Here are the code: In user.java: Code: ... @Entity @Table(name="Users") @SequenceGenerator(name="user_gen", sequenceName="user_id_seq") public class User implements Serializable { @Id @GeneratedValue(strategy=GenerationType.IDENTITY, generator="user_gen") private ...

90. help! newbie here.. @onetomany with arraylist    forum.hibernate.org

Hi, I've been over two days searching for a solution and I'm not been able to find a solution or an explanation. Maybe someone here could help me. I want to use a ordered collection with @onetomany. Here are fragments of my entities: Order.class @OneToMany(cascade=CascadeType.ALL, targetEntity=OrderLine.class, mappedBy="order") @OrderBy("date") private List orderLines = new ArrayList(); OrderLine.class @ManytoOne Order order; This don't work: ...

91. Simple @OneToMany mapping question    forum.hibernate.org

hello, I have projects which contain SequenceLists: Code: @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY) @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN}) private List hitlists; ...

92. OneToMany on (filtered) DB view    forum.hibernate.org

93. Problems saving an unidirectional OneToMany relation    forum.hibernate.org

I have a problem, persisting a unidirectional onetomany relation. Here is the code: Code: @Entity public class Customer extends Person { @Id @GeneratedValue protected Long id; ... @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinTable( ...

94. LIE on OnetoMany Collection with query and 2nd lev. cache on    forum.hibernate.org

Newbie Joined: Thu Feb 17, 2011 7:26 pm Posts: 1 We have an LazyInitializationException on a OneToMany association only when local query and 2nd level entity cache is enabled. When local query cache is disabled, the exception goes away. Initializing the collection in the session also makes the LIE not happen. We are using, see below, a named query to custom ...

95. Which jpa method called on collections in OneToMany    forum.hibernate.org

My Spring/Hibernate Versions: spring 2.5.6 hibernate-3.2.2.ga hibernate-annotations-3.2.1.ga hibernate-entitymanager-3.2.1.ga I have an AspectJ pointcut that is intercepting the known 'save/update' methods for a JPA EntityManager but am unsure how to know during a cascading-save what method is actually being called on the children??? The documentation claims: #If a parent is passed to persist(), all children are passed to persist() #If a parent ...

96. @OneToMany mapping to a Map question    forum.hibernate.org

97. OneToMany - Unidirectional - without Join Table - problem    forum.hibernate.org

@Entity @Table(name="TABLE1") Class ClassA{ . . . @Column(name="REF_B") private String a_obj; ...

98. Unidirectional OneToMany reverse?    forum.hibernate.org

public class Lieferant { @Id @GeneratedValue protected long id; @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinTable( joinColumns=@JoinColumn(name="lieferantid", referencedColumnName="id"), inverseJoinColumns=@JoinColumn(name="userid", referencedColumnName="id") ) private Set users = new HashSet(); }

100. Set null value on delete with @OneToMany    forum.hibernate.org

Hi, I have two classes, Person and Position. One Person can be assigned to many Positions, and one Position can have only one Person (or no Person assigned). Everything works fine, but deletions of Persons. ConstraintViolationException occurs. And when I use "cascade=CascadeType.ALL" it deletes Position too, what I don't want to. I need to set annotations to achieve this: when I ...