many-to-one

NHibernate Cascade none still updating related entity.

Hi, I am then using Fluent NHibernate and its automapping feature to map the the following simplified POCO classes: public class Webpage { public virtual int Id { get; set; } public virtual string UrlIdentifier { get; set; } public virtual WebpageType WebpageType { get; set; } } public class WebpageType { public vi...

Hibernate many to one delets all parents when a child is deleted

I have Country and State objects. I intend to have unidirectional many to one relationship from State to Country. I don't want to store any references to States in Country I have defined mapping as below. When I delete even one State object, all Countries are deleted! <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hib...

Hibernate: Many-to-one using Formula

Hi everybody, I hope someone can help me find an answer. I'm working with a legacy database and I can't change any of the preexisting tables, because other apps depend on them. I have three main existing tables: A,B,C. A has a column with reference to B(many to one relation). The problem is that it should have a relation to C not to B...

How do I left join tables in unidirectional many-to-one in Hibernate?

I'm piggy-backing off of http://stackoverflow.com/questions/2368195/how-to-join-tables-in-unidirectional-many-to-one-condition. If you have two classes: class A { @Id public Long id; } class B { @Id public Long id; @ManyToOne @JoinColumn(name = "parent_id", referencedColumnName = "id") public A parent; } ...

nhibernate mapping does not save/insert keys of inserted subclasses

After having changed around my mappings a bit ( see my other question about cascade-delete for reasons) , i tried inserting a completely new object and all its subclasses. After this another problem emerged, an issue with the insertion of the keys into the database. Situation is as follows: I have an object with 2 tiers of subclasses, ...

hibernate foreign key mapping many-to-one

I have been working on it for quite a while, but still can't figure out what's wrong with my code. Each Service has multiple profiles, but each profile only has one Service. Service { Long service_id; // primary key ... getter/setter } Profile { Long profile_id; // primary key Long service_id; // foreign key ... getter and setter } i...

Excel VBA merge many columns into one on separate rows

I have a large array of cells in multiple columns that need to be combined into one large column with a new row for each cell. I do NOT want to merge the contents of any cells. ...

NHibernate: bidirectional many-to-one problem

I have a bidirectional relationship in NHibernate: <class name="Child" table="Children"> <many-to-one name="Parent" column="ParentId" not-null="true" /> </class> <class name="Parent"> <set name="Children" lazy="true" table="Children" cascade="all"> <key column="ParentId" not-null="true" /> <one-to-many class="Child" /> </...

Update one-to-many EntityKey using Foreign Key

To use by the easiest way Entity Framework, I use partial class to add Foreign Key on most important Entities Model. For example, I have an Entity "CONTACT" which have "TITLE", "FUNCTION" and others. When I update a CONTACT, with this code, Foreign Key are automatically updated : public int? TitId { get { if (this.TITLE...

Hibernate criteria query using Max() projection on key field and group by foreign primary key

I'm having difficulty representing this query (which works on the database directly) as a criteria query in Hibernate (version 3.2.5): SELECT s.* FROM ftp_status s WHERE (s.datetime,s.connectionid) IN (SELECT MAX(f.datetime), f.connectionid FROM...

JPA @OneToMany and composite PK

Good Morning, I am working on project using JPA. I need to use a @OneToMany mapping on a class that has three primary keys. You can find the errors and the classes after this. If anyone has an idea! Thanks in advance! FF javax.persistence.PersistenceException: No Persistence provider for EntityManager named JTA_pacePersistence: P...

JoinColumn name not used in sql

Hi! I have a problem with mapping many-to-one relationship without exact foreign key constraint set in database. I use OpenJPA implementation with MySql database, but the problem is with generated sql scripts for insert and select statements. I have LegalEntity table which contains RootId column (among others). I also have Address tabl...

Hibernate fetches incorrectly using @ManyToOne EAGER

I have two entities, let's call them X and Y. They have many-to-many relation but I never needed to use that relation, i.e x.getYs(), so I did not set it up to keep things simple. I have a table that holds the relationship and has only rows that are keys to X and Y. In other words that x_y table's rows are only x_id and y_id What I need...

Nhibernate Migration from 1.0.2.0 to 2.1.2 and many-to-one save problems

Hi, we have an old, big asp.net application with nhibernate, which we are extending and upgrading some parts of it. NHibernate that was used was pretty old ( 1.0.2.0), so we decided to upgrade to ( 2.1.2) for the new features. HBM files are generated through custom template with MyGeneration. Everything went quite smoothly, except for o...

NHibernate, could not load an entity when column exists in the database.

This is probably a simple question to answer but I just can't figure it out. I have a "Company" class with a many-to-one to "Address" which has a many to one to a composite id in "City". When I load a "Company" it loads the "Address", but if I call any property of "Address" I get the error: {"could not load an entity: [IDI.Domain.Ent...

Hibernate annotated many-to-one not adding child to parent Collection

I have the following annotated Hibernate entity classes: @Entity public class Cat { @Column(name = "ID") @GeneratedValue(strategy = GenerationType.AUTO) @Id private Long id; @OneToMany(mappedBy = "cat", cascade = CascadeType.ALL, fetch = FetchType.EAGER) private Set<Kitten> kittens = new HashSet<Kitten>(); public v...

What's the best way to index many-to-one relation with hibernate search?

I have an entity with many-to-one mapping. (Product 1-* Regions, unidirectional association) What is the best way to store index of such relation? So it can be easily used to filter search query . ...

Many-to-one relationship in SQLAlchemy

This is a beginner-level question. I have a catalog of mtypes: mtype_id name 1 'mtype1' 2 'mtype2' [etc] and a catalog of Objects, which must have an associated mtype: obj_id mtype_id name 1 1 'obj1' 2 1 'obj2' 3 2 'obj3' [etc] I am trying to do this in SQLAlchemy by creating the f...

Two entities with @ManyToOne should join the same table

I have the following entities Student @Entity public class Student implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; //getter and setter for id } Teacher @Entity public class Teacher implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Lo...

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...