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...
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...
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...
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;
}
...
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, ...
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...
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.
...
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" />
</...
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...
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...
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...
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...
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...
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...
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...
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...
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 .
...
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...
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...
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...