orm

Do migrations suck, or is it just me?

Migrations are undoubtedly better than just firing up phpMyAdmin and changing the schema willy-nilly (as I did during my php days), but after using them for awhile, I think they're fatally flawed. Version control is a solved problem. The main function of migrations is to keep a history of changes to your database. But storing a differen...

In designing a DB schema is it generally the case that tables representing a child property (in the OO world) should reference their parent?

It's been a while since I've had to work with relational databases (I've been avoiding it as much as I can in my personal projects, and at work we use an object database) so I'm fairly sure this is the correct way, but I wanted to make sure. When modeling a relational database from an existing object hierarchy it is generally the case t...

Django GROUP BY strftime date format

I would like to do a SUM on rows in a database and group by date. I am trying to run this SQL query using Django aggregates and annotations: select strftime('%m/%d/%Y', time_stamp) as the_date, sum(numbers_data) from my_model group by the_date; I tried the following: data = My_Model.objects.values("strftime('%m/%d/%Y', ...

What .NET ORMs support smart clients (ie object mapping and data synchronization)

I was recently involved in a project that required a smart client. We used SQL Server Compact Edition and Microsoft Sync Services for ADO.NET. Our online server was SQL Server 2005. A quasi-ORM/DAL (very specific to our needs) was handcoded by a member of our team. Creating a custom ORM in this scenario cost us quite alot of development ...

Can I create a table (if not exists) from Rose::DB::Object metadata?

I'm having trouble finding it in the CPAN documentation -- is there a way to create a table (IF NOT EXISTS) from manually-entered Rose::DB::Object metadata? I'm using SQLite as an engine, if it happens to matter. Thanks! ...

Using NHibernate for SQL query generation

NHibernate provides us with ORM capabilities. Part of NHibernate generates queries based on mappings and HQL (or ICriteria). I'm wondering if it is possible to use NHibernate for generating queries against databases without using its ORM capabilities. I'm trying to provide customers with custom access to their database. Since the schema...

How to setup a property from 1 linq2sql obj that is populated by a relationship to another obj

I'm using Linq2SQL and I'm pretty new to it. I've got a User table and a UserData table, the idea being that properties for the User object can be added / removed by adding or removing rows in the UserData table. I did not come up with this particular design but I am more or less stuck with it (as long as I can come up with a solution)...

ADO.NET Entity Framework and NHibernate - when to use one over the other

I am working in a Microsoft .NET shop where it is okay to use NHibernate or ADO.NET EF. What guidance should we be using about when you should choose one over the other? For example, it seems like when writing a Silverlight app the EF -to-> ADO.NET Data Services -to-> Silverlight would offer a productivity boost, and provide you with a ...

Lightspeed vs NHibernate

What is the experience with LightSpeed? The comparison provided by Mindscape doesn't say too much about NHibernate. Lightspeed seems flexible, but I don't see much about performance. How well does Lightspeed perform? Also are there any drawbacks to using Lightspeed? ...

Linq to SQL ORM 3-layer question

I am designing this HR System (desktop-based) for a mid-size organization. The thing is I have all the tables designed and was planning on using the O/RM in VS2008 to generate the entity classes (this is the first time I work with OR/M; in fact, this is my first "big" project.) I wanted to make the app with 3 layers (one of the programme...

ASP.NET DataSet vs Business Objects / ORM

I'm thinking through data access for an ASP.NET application. Coming from a company that uses a lot of Windows applications with Client Data sets there is a natural dendancy towards a DataSet approach for dealing with data. I'm more keen on a Business Object approach and I don't like the idea of caching a DataSet in the session then appl...

How to batch delete using bulkUpdate

I have a common User / Role setup, with a user_role join table. I'm trying to use Spring's HibernateTemplate to mass delete all locked users like this: getHibernateTemplate().bulkUpdate("delete from User where locked=?", true); If the user being deleted does not have any roles (no record in the user_role table), then everything goes f...

What is a good balance in an MVC model to have efficient data access?

I am working on a few PHP projects that use MVC frameworks, and while they all have different ways of retrieving objects from the database, it always seems that nothing beats writing your SQL queries by hand as far as speed and cutting down on the number of queries. For example, one of my web projects (written by a junior developer) exe...

Mapping enum to a table with hibernate annotation

I have a table DEAL and a table DEAL_TYPE. I would like to map this code: public class Deal { DealType type; } public enum DealType { BASE("Base"), EXTRA("Extra"); } The problem is that the data already exist in the database. And I'm having a hard time mapping the classes to the database. The database looks something like that...

What am I missing about SqlAlchemy?

So I wanted to introduce a friend to the wonderful world of python ORM libraries, which I still know little about. Our databases are extremely fragmented and at times under normalized (for efficiency) and over normalized. Making "entities" out of it at this point is too much work (we have lots of legacy php code working with this) so th...

Linq to SQL - many to many mapping

Hello, In my project I have 'Player'(PlayerID and data) table, 'Games' table (GameID, Name) and I made a many to many table 'PlayerGames' (PlayerID, GameID - I created the forign keys relations) PlayerID and GameID are primary keys in their tables and the tuple (PlayerID,GameID) are primary key in 'PlayerGames' Table I tried to map th...

What ORM would you choose for working with legacy databases ?

I am in the process of integrating a number of legacy systems. They each have different databases; and I will need to write data access code for most of them. The database schemas cannot be changed (I might be able to apply some indexes and such, but tables and their columns must retain the structure). Some of the databases has an OK de...

Usage of ORMs like NHibernate when there are many associations - performance concerns

I have created an application (a web-based application) which now has a large number of associations. Simply put, an Account: has many Users has Settings has many Projects Similarly a Project: has many Items A User: has many Tasks And so on, with loads more associations. Nothing particularly unusual about that I hope. I chose...

Migrating from 'native' OODBMS to ORM (Entity Framework / SQL Server)

A while ago we started developing a new project which internally has about 25-30 different classes/types/models that are heavily related to each other either via 1:n, n:m or n:1 relationships. Back then we went with a native .net oodbms system basically because what it allowed us to do was to take our object model and simply add a few p...

ORM - Saving/Restoring default values for a DB object with C#

In order to assist users with repetitve data entry, I am trying to implement a system where many of the previous properties are remembered when adding new data. Is it possible to use the Properties.Settings.Default.MySetting functionality or is there a better method for doing this kind of thing? ...