orm

problem when retrieve data from hibernate many to many relationship

i have two table with many to many relationship when i apply findbyall method to this table it will retrieve one record multiple time (that is the record will be displayed for this perticular table as many time as there are different relation ship with other table) so how can i display each record once only. thank in advance. ...

Querying "extension tables" using Hibernate

I am having a querying issue in Hibernate. I have a table, 'test', with existing data. I have a requirement where I can not modify the schema of the test table, so I created another table, 'testExtension', whose primary key is a foreign key to the primary key of Test. Data in testExtension is a subset of the data in test. i.e. There w...

Fluent NHibernate Mapping Issue.

Hey everyone. I am trying to map several tables using Fluent Nhibernate. My tests are giving me the following error: NHibernate.Exceptions.GenericADOException: could not initialize a collection: [FluentWeb.Domain.Employees.Orders#1] I am trying to map a one to many relationship between Employees and Orders. Orders then has a many to ma...

Data Access Layer in .net

Hi, I am designing an application where I want to reduce the burden on the developers for future for development. In this I have list of classes e.g-"User,Account,Permission and etc" now these classes are associated to the table in the database with the name of the class same as data table. I want my business layer to be robust so that i...

What are the pros/cons of returning POCO objects from a Repository rathen than EF Entities?

Following the way Rob does it, I have the classes that are generated by the Linq to SQL wizard, and then a copy of those classes that are POCOs. In my repositories I return these POCOs rather than the Linq to SQL models: return from c in DataContext.Customer where c.ID == id select new MyPocoModels.Customer { ID = c.ID, ...

Reconstituting domain objects from database: identity problem

We are using Linq to SQL to read and write our domain objects to a SQL Server database. We are exposing a number of services (via WCF) to do various operations. Conecptually, the implementation of these operations consists of three steps: reconstitute the necessary domain objects from the database; execute the operation on the domain ob...

Create db schema from domain objects in .NET

In EJB 3.0 you can write your domain objecs, then convert them into entitities (adding @Entity attribute, etc.) and underlying JPA mechanism (let's say Hibernate) can automaticly generate db schema. What's better it will also update db when you update you domain model in Java code. I'm looking for equivalent of that functionality on .N...

Fetching customer orders: Set<Order> getAllOrders() vs. Set<Integer> getAllOrders()

I haven’t done much Java programming and hence a lot of unanswered ORM questions revolve in my head that might seem as fairly straight forward to more seasoned folks. Let's say we have two classes: Customer and Order. Customer class implements a method called listAllOrders, what should the method’s signature be? Set<Order> getAllOrde...

one-to-many mapping // how to map an association of legacy tables (Hibernate)

Hi all, I've got two legacy database tables, layouted in simplified manner like this: MASTER SLAVE ident ident sName sName sNumber sNumber sDesc sValue ----- ------ Java Class 'ScenarioMaster' ...

Fluent Nhibernate Generates Invalid column names in One-to-Many

Hello.. Fluent NHibernate Generates invalid columns names within a Many to one relationship. enter public EmployeeMap() { Id(x => x.EmployeeID); Map(x => x.FirstName); Map(x => x.LastName); Map(x => x.City); Map(x => x.HireDate); Map(x => x.Title); HasMany(x => x.Orders) ...

Django ORM: Selecting related set

Say I have 2 models: class Poll(models.Model): category = models.CharField(u"Category", max_length = 64) [...] class Choice(models.Model): poll = models.ForeignKey(Poll) [...] Given a Poll object, I can query its choices with: poll.choice_set.all() But, is there a utility function to query all choices from a set of...

Would I use an ORM if I am using Stored Procedures?

If I use stored procedures, can I use an ORM? EDIT: If I can use a ORM, doesn't that defeat part of the database agnosticity reason for using an ORM? In other words, why else would I want to use an ORM, if I am binding myself to a particular database with stored procedures (or is that assumption wrong)? ...

Optimize NHibernate Query

Hi In my system I do a centralized calculation on an aggregate with a lot of collections. I need ALL of the collections to be loaded before the calculation, and therefore I use a multicriteria that joins the collections on the root. The criteria i listed here below. It takes approx 500ms to run on my local setup, and that is a lot of ...

Learn SubSonic before NHibernate or Vice Versa?

We've been using our own DAL for our projects in our company and for the passed 2 projects this has causing us problems. Because of this I want to study SubSonic and/or NHibernate. Is it better to study SubSonic first or NHibernate? What are the advantages/disadvantages? From what I have read from related questions here NHibernate is mor...

Hibernate L2 Caching and Many-To-Many relationships

I've got a pair of Hibernate entities, A and B, that are related via a bidirectional many-to-many relationship, as described here - ie, each entity has a bag referencing a collection of the other type of entity, with a link table comprising the primary key of each entity. I am also using Hibernate L2 caching to cache the collection valu...

SQLAlchemy is convoluted?

This may seems rather argumentative, but I just went through SQLAlchemy's ORM tutorial and ended up with the following code: from sqlalchemy import create_engine from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker eng...

Id or [TableName]Id as primary key / entity identifier

Is it preferred to use "Id" as the column name for a primary key or "[TableName]Id" as a naming convention? Table: Account Primary Key: Id -- versus -- Table: Account Primary Key: AccountId It seems to be split about 50% / 50% in the implementations that I've seen. What are the advantages and disadvantages in each approac...

How to build a java web application

Hi, Soon I will have to start a web project for a company, and I now need to choose a technology to build the app. I'm thinking about using Java, hence I'd like to find a framework that will help me building the app (I'm used to PHP framework such as CakePHP & CodeIgniter). What I don't understand is that it seems to exist a lot of fra...

JPA: Should I clean up my entity classes using orm.xml?

I currently use JPA annotations only, but I really don't like that I'm polluting my entity classes with so many ORM details which really aren't relevant to their behavior (e.g. table name, id generation strategies, join columns...). I see that DataNucleus recommends putting ORM-related annotations in XML instead (those colored in pink),...

List of non-datastore types in AppEngine?

I'm building an AppEngine model class. I need a simple list of tuples: class MyTuple(object): field1 = "string" field2 = 3 class MyModel(db.Model): the_list = db.ListProperty(MyTuple) This does not work, since AppEngine does not accept MyTuple as a valid field. Solutions I can think of: Make MyTuple extend db.Model. But does...