one-to-many

PHP or C# script to parse CSV table values to fill in one-to-many table

I'm looking for an example of how to split-out comma-delimited data in a field of one table, and fill in a second table with those individual elements, in order to make a one-to-many relational database schema. This is probably really simple, but let me give an example: I'll start with everything in one table, Widgets, which has a "stat...

Difference Between One-to-Many/Many-to-One and Many-to-Many?

Ok so this is probably a trivial question but I'm having trouble visualizing and understanding the differences and when to use each. I'm also a little unclear as to how concepts like unidirectional and bidirectional mappings affect the one-to-many/many-to-many relationships. I'm using Hibernate right now so any explanation that's ORM rel...

Relational database Design- Relationship problem

Hi I need to create database tables to store memo. in the "To" clause user may select individual employee or group of employees (Different groups are already available in database having many to many relationship with employee). i am wondering what should be structure of tables. For simple memo where there are no groups i will have "Memo...

Grails finding parent by the many side

Hi, My problem should be obvious, but I just don't see the light right now :-( I have two domainclasses like this: class Parent { String name static hasMany = [children: Child] } class Child { String name } Now I should be able to find the Parent of a child by using the dynamic finder of the Parent like: Parent.findByChild...

How to Stop Hibernate From Trying to Update one-to-many Over Join Table

Ok so I'm having bit of a problem with my Hibernate mappings and getting the desired behavior. Basically what I have is the following Hibernate mapping: <hibernate-mapping> <class name="com.package.Person" table="PERSON" schema="MYSCHEMA" lazy="false"> <id name="personId" column="PERSON_ID" type="java.lang.Long"> ...

Need some explanations on NHibernate many to one relationships

Hello everybody, would you mind help me to better understand what to do with the relationship between my entities and NHibernate? I have some difficulties to understand what operations I need to do by hand, and what operations NHibernate will do for me (or not). I have these 2 entities: public class Position : BaseEntity<int, Positio...

fluent map one to many

Class Person { int ID; IList<Cat> cats; } Class Cat { int OwnerId; } how to map person cats on nhibernate fluent? probably stupid question but i cant find the answer.. thank you all. ...

Hibernate - One to many relationship and orphanRemoval cascade

Hi, I have a basic one to many relation parent / child like in the chapter 21 of Hibernate references book. The cascade is only from child to parent (persist cascade only because I don't want to delete the parent if I delete a child). When I add a child to the parent and I save the child, I have a TransientObjectException... @Entity pu...

LINQ 2 SQL Return Multiple as Single String

I have a 1 to Many relationship between tblBusiness and tblPhone. For a specific BusinessID I am trying to return a single string of information to bind to a textbox. Below is my latest attempt along with the Generated SQL from that same LINQ. No matter WHAT I have tried it returns NULL unless there is a value for all 3 fields. What ...

Hibernate one-to-many search with Criteria

Hi all, I've got a Hibernate entity, called Event, which has a one-to-many metadata entity, EventData. Given the following Event: EventId: 1 EventHash: broccoli With the following EventDatas: EventDataId: 1 EventId:1 Field: tag Content: tagme EventDataId: 2 EventId: 1 Field: tag Content: anotherTag How do I create a Criteria que...

how to create one-to-many relevance on google-app-engine

like one forum has many topic , ths specific is : forum and topic has the same model : class Geo(db.Model): #self = db.SelfReferenceProperty() title = db.StringProperty() link = db.StringProperty() updated = db.DateTimeProperty(auto_now =True) author = db.ReferenceProperty(MyUser) id = db.StringProperty() e...

UI pattern to allow user to add item with unlimited sub-items

Hi all I'm writing an ASP.NET app. I need to include a page where the user can add an item which has several sets of subitems, each of which sets is unlimited in number. The subitems themselves contain between 10 and 15 fields, so need a fair bit of UI space. As an example of what I mean, the user needs to be able to add a Business rec...

Nhibernate one-to-many lazy loading not working as expected.

Consider the following scenario: Class A has a one-to-many relationship to Class B. Class B has a many-to-one relationship to Class C. class A { IList<B> BList {get;set;} } class B { C CMember{get;set;} } class C { //null } If I load class B from the database using something like IList<B> result = query.List<B>(); every...

JPA OneToMany problems after update

I have 2 Classes, Parent and Child, with a @OneToMany relationship. Every parent has 0 or more children. @OneToMany(fetch=FetchType.LAZY, cascade={CascadeType.REMOVE}) The Parent class has also other fields like the name. I'm in a Container env, so my UI is made of JSP. When I want to change the Parent object I have to pass it to a...

SQL join on one-to-many relation where none of the many match a given value

Say I have two tables User ----- id first_name last_name User_Prefs ----- user_id pref Sample data in User_Prefs might be user_id | pref 2 | SMS_NOTIFICATION 2 | EMAIL_OPT_OUT 2 | PINK_BACKGROUND_ON_FRIDAYS And some users might have no corresponding rows in User_Prefs. I need to query for the first name and l...

one to many join on 3 levels all on the same table

I have this table with pages, these pages have parents that are also pages in the same table. For this examples sake the table looks like: table: Pages PageId :Key PageParent :Foreign Key PageName Now my question is what would the SQL look like when creating a menustructure like: PageId PageParent PageName 1 NULL ...

hibernate bidirectional one-to-many inserts duplicates

Hello everyone. I'm having issues with a parent-child relationship here. When I persist from the collection side (child side) I get 2 new children instead of one. Here is are the hibernate mappings: <set name="children" inverse="true" cascade="all,delete-orphan" lazy="true" order-by="CHILD_ID desc"> <key...

MySQL Query "One to Many" question.

OK I am going to try to explain this the best I can and maybe someone will understand it. I have a CRM application I am building and have the following tables: contacts, email, phone, website and address. I have been trying to create a Query that gathers all the info into one result set. I have kind of found a way that works 99.9% but I ...

JPA: How to have one-to-many relation of the same Entity type.

There's an Entity Class "A". Class A might have children of the same type "A". Also "A" should hold it's parent if it is a child. Is this possible? If so how should I map the relations in the Entity class? ["A" has an id column.] ...

Getting the ID of the persisted child object in a one-to-many relationship.

I have two entity classes A and B which looks as follows. public class A{ @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @OneToMany(mappedBy = "a", fetch = FetchType.LAZY, cascade = {CascadeType.ALL}) private List<B> blist = new ArrayList<B>(); //Other class members; } Class B: pu...