orm

Is using DTO's and Entities breach of DRY principle ?

I was looking at a library called Automapper. I am having a few concerns with this: We dont want to expose our data model (GOOD). Why should the datamodel closely resemble your DB? using lightweight DTOs instead of your entities. (GOOD) Now I need to map my entities to these DTOs. Am i respecting the DRY principle?? ...

Saving and retrieving inherited types with LINQtoSQL and Business Objects

I have an abstract EventBase class and some inherited event types, along with an Event class. Each event type has its own unique columns. In my data layer, I have a GetEvents method that simply does: from e in db.Events select new Event {...values...}; EventType is an enum which matches up to an EventTypes table I want GetEve...

Picking an ORM tool - So many choices, and so little time...

Hi All, After much reading, playing and fiddling, I am still not sure what ORM tool is the one i should be using above others.I am usign the Dotnet stack. I have looked at, Entity framework, LLBLgen Pro, NHibernate. Currenlty I am rather impressed with LLBLGen Pro. I have also read about Castle's active record, sub sonic and Linq to S...

How to use second level cache for lazy loaded collections in Hibernate?

Let's say I have two entities, Employee and Skill. Every employee has a set of skills. Now when I load the skills lazily through the Employee instances the cache is not used for skills in different instances of Employee. Let's Consider the following data set. Employee - 1 : Java, PHP Employee - 2 : Java, PHP When I load Employee - ...

Knowing when hitting database vs cache

Given all the smarts around Hibernate and it's various caching strategies, how do I know if a certain operation is resulting in a physical database hit, or coming from the cache? ...

Migrating to ORM

Stepwise, what would be a good way of integrating Spring and Hibernate into an existing JSF application that doesn't use ORM? ...

How do i create a Hibernate Criteria to order by some properties of collection

Say, i have an entity that has a history of operations as a collection. I want to sort entities by the date of the latest operation (it's the first element of history). i'd like to do something like this: criteria.addOrder(Order("history[0].date")) is this possible? ...

DRYing c++ structure

I have a simple c++ struct that is extensively used in a program. Now I wish to persist the structure in a sqlite database as individual fields (iow not as a blob). What good ways are there to map the attributes of the struct to database columns? ...

How do you handle these common problems WITHOUT using an ORM and using straight JDBC (or equivalent)?

Wnen using just JDBC, I typically have to think about the following problems. I don't think too hard and just make something work, but I am wondering how people handle these without an ORM or other library. Eager vs Lazy Loading: Do you just have a single domain object and have the dependent children be null and make it the responsibil...

Doctrine - all records are returned when there are no matches in Searchable behavior

I'm using the Searchable behavior in Doctrine to search for products in my catalog. It works great when searching for keywords that do match a product. For example, the keyword "Backpack" returns all products with the word "Backpack" in the title. However, when a search is done for a keyword that doesn't match a title at all then every...

What is the actual benefit of ADO.NET Entity Framework?

I was reading this article about ADO.NET Entity Framework and found it to be very interesting though in the first shot I could not decipher many things. I am reading the article again in order to fathom the real logic behind this. a) A question cropped in my mind is why we need an ORM framework (in general)? b) And among other ORM fra...

Hibernate HQL with interfaces

According to this section of the Hibernate documentation I should be able to query any java class in HQL http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html#queryhql-polymorphism Unfortunately when I run this query... "from Transaction trans where trans.envelopeId=:envelopeId" I get the message "Transaction is n...

hibernate and netbeans application

how i configuration hibernate and netbeans>??give simple tutorial with some example ...

Hibernate / MySQL Bulk insert problem

I'm having trouble getting Hibernate to perform a bulk insert on MySQL. I'm using Hibernate 3.3 and MySQL 5.1 At a high level, this is what's happening: @Transactional public Set<Long> doUpdate(Project project, IRepository externalSource) { List<IEntity> entities = externalSource.loadEntites(); buildEntities(entities, project)...

Can someone explain why the following DQL works?

$user = Doctrine_Core::getTable('User') ->createQuery('u') ->innerJoin('u.Profile p') ->where('p.username = ?', 'jwage') ->fetchOne(); It looks quite different from SQL which I'm quite used to,especially what does the u mean? Can someone make it clear by a decent explanation? ...

Error in creating alias in formula tag

Hi all I have a sql query in formula tag inside property tag. In that query i am creating alias name but the hibernate appends table name and throwing me error. select sum(e.salary) as sal from employee e but hibernate changes to select sum(e.salary) as employee.sal from employee e how to avoid this .... it should recognise as sa...

How to force NHibernate not to update all objects in collection

Hi guys. How to force NHibernate not to generate UPDATE for each element in collection if I change only one element of that collection. Here it is: internal class Master { private int _id; public string Name { get; set; } public ISet<Slave> Slaves { get; set; } public Master() { Slaves = new HashedSet<Slave...

Where should I store virtual/calculated/complex object fields in my models?

I have models corresponding to database tables. For example, the House class has "color", "price", "square_feet", "real_estate_agent_id" columns. It is very common for me to want to display the agent name when I display information about a house. As a result, my House class has the following fields: class House { String color; Do...

Django: show/log ORM sql calls from python shell

Using the excellent Django-Devserver I'm finding all kinds of interesting and unexpected SQL calls in my code. I wanted to find where the calls are coming from, and so I'm looking for a way to get a log or print-out of all SQL calls generated by the Django ORM in the Python shell. That is, when I do a Django ORM call via the Python shell...

Setting up relations/mappings for a SQLAlchemy many-to-many database

I'm new to SQLAlchemy and relational databases, and I'm trying to set up a model for an annotated lexicon. I want to support an arbitrary number of key-value annotations for the words which can be added or removed at runtime. Since there will be a lot of repetition in the names of the keys, I don't want to use this solution directly, a...