one-to-many

Hibernate WrongClassException / Sets / Discriminators?

Hi, The problem looks like this: A Product table. 3 joined-subclasses: DVD, CD, Book. A Role table (composite id: NAME, ROLE, PRODUCT), and subclasses by discriminator column ROLE: actor, director, artist, author, etc.. which are mapped to Actor, Director, Artist, Author java classes; (pretty usual I guess) ... A Book has authors, a C...

SubSonic 3 - Simple repository - One to many relations

Hi, It's the first time I use Subsonic. Let say I have those classes : public class Store { public int Id { get; set; } public String Name { get; set; } } public class Employee { public int Id { get; set; } public String Name { get; set; } } An employee is related to a store with is hired date. This means that in th...

Hibernate unidirectional one to many association - why is a join table better?

In this document (scroll down to the Unidirectional section): http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity-mapping-association-collections it says that a unidirectional one-to-many association with a join table is much preferred to just using a foreign key column in the owned entity. My question i...

Many to one join help for flat file

I’m not sure if this has already been asked – I looked around for quite a bit but couldn’t find anything. My end result is to get data from several of my SQL database tables into a comma delimited flat file. Normally this would not be a problem but due to their many to one relationship and the format I’m forced to put it in it’s proving...

SubSonic 3 SimpleRepository One-to-many

Hi! How do I handle relations in SubSonic 3 using the SimpleRepository? E.g: Having Author and Book (see below) I want the assigned Author to be persisted when the Book is persisted. [Serializable] public class Book { public int Id { get; set; } public string Title { get; set; } public Author Author { get; set; } } [Serial...

Fluent nHibernate: one-to-many relationship problem

I have a problem with one-to-many relationships. I have the following domain classes: public class Installation : Entity<Installation> { public virtual string Name { get; set; } public virtual IList<Institution> Institutions { get; set; } public Installation() { Institutions = new List<Institution>(); ...

ActiveRecord - Self Referencing Associations

I'm a total Ruby/Rails/AR noob. I have a very basic sort of database schema that I can't seem to figure out the best way to represent in the Rails Way. Table Post String title, author Text content Timestamp posted Post parent The idea here is that top level posts will have parent that is NULL. Every response will hav...

Why find(:last) fail in my unit tests?

I have a one-to many relationship in Rails: class User < ActiveRecord::Base has_many :activities, :order => "added_at DESC" class Activity < ActiveRecord::Base belongs_to :user I have a method in Activity: def self.test_message(user, message) user.activities << Activity.create do |activity| activity.message = message ...

Commit a change to more than one branch in Git

Typical usage scenario: I have master, branch_foo and branch_bar. All are up to date. Now, I do a "git checkout master" and work on a bug fix. Lets say that fix was on a tracked file that is in the same state on all branches - ie. before the fix, a diff of the file from each branch results in no differences. Is there a way to commit...

Override targEntity in descendant entity bean

I have two separate databases that contain a report and reportItems table. The table structure is the same for both databases. I have a session bean that needs to write to each database / table. In order to keep the code simple I want the session bean to work with a base entity bean that then goes to the appropriate table. To accomplis...

Linq to Sql Many-One relationship

I have 2 views in SQL set up: PurchaseOrder PurchaseOrderLineItems These have many columns aliased (the tables they view/join are not sensibly named... it's a 3rd party product) I have 2 classes (simplified below) class PurchaseOrder { public string PoNumber { get; set; } public string Vendor { get; set; } ...

JPA one-to-many relationship question (relations on one entity)

In this JPA example there is a code: @OneToOne(cascade=CascadeType.ALL) private Deity mother; @OneToOne(cascade=CascadeType.ALL) private Deity father; @OneToMany(cascade=CascadeType.ALL) private Set<Deity> children; Why relation with father and mother is implemented by @OneToOne annotation and not in @ManyToOne relation? If Child an...

Correct NHibernate mapping for a specific scenario (one-to-many/one-to-one)

I had a following structure: User has many books in his history which was translated to the following class User { ICollection<Book> History } // C# User -> UserHistory (UserId, BookId) -> Book // DB Now I want to add a date to the history, creating the following class structure: class User { ICollection<Read> History } ...

Subsonic - can anyone provide an example of using Subsonic SimpleRepository to persist a list/array of objects?

I'm looking for possible ways to persist the following classes. Subsonic SimpleRepository looks like it might work, and people have said it should, when I asked a more general question. But I've been unable to find a single example of how to do this - or at least one I could understand. Can anyone point me to an example, or tell me ...

nHibernate one-to-many mapping question

Hello folks, I am getting this exception when mapping one-to-many relation. my mapping xml looks like this: <set name="-----" generic="true" inverse="true" cascade="all" lazy="false"> <key column="Id" /> <one-to-many class="-----------,---------" /> </set> And, <many-to-one name="------" column="Id" not-null="true" cla...

Fluent NHibernate AutoMapping throws "StaleStateException" when try to Commit a List<>

The following code throws a StaleStateException exception when the Order.OrderItems property (an IList) is Commited. The full text of the exception is: An unhandled exception of type 'NHibernate.StaleStateException' occurred in NHibernate.dll Additional information: Unexpected row count: 0; expected: 1 I've just started using NHibern...

Acts_as_tree - one-to-Many: Show Records associated with children on parent page

Hi, I have a relatively simple one-to-many relationship and use acts_as_tree to get it organized in the view. It kinda looks like this: Root |_Product 1 |_Product 2 |_Category 1.1 |_Product 3 |_Product 4 |_Category 1.1.1 |_Product 5 The way I set it up is that I list products in the 'sh...

One-to-Many Unidirectional Parent-Child ID Cascade Save

When trying to save an ID from my parent class into a child class, I keep getting the error "ERROR - Field 'parent_id' doesn't have a default value" I have tried all types of mappings. I am using annotations. Any help on this would be appreciated Parent: @Id @Column(name="id") @GeneratedValue(strategy=GenerationTyp...

Value object or entity object in my Hibernate mapping?

Hey everyone, I'm trying to design a pretty simple app and am getting myself a bit confused with Hibernate's definition of entity and value objects (as defined in Chapter 4 of Java Persistence with Hibernate). What I have is an app with customers, who can place orders (one to many relationship). Each of these orders has many order line...

Core Data: re-setting to-many relationship

Hi, I have created model which you can see there: http://i.imagehost.org/0836/2009-11-08%5F14%5F37%5F41.png I want to store information about sound categories and some sample sounds for each category. Category has Name (NSString) and SoundsRelation (NSSet of NSData, which represents sounds). Here is the problem: For example I have som...