orm

Java static reflection on subclasses

Hi all. I am implementing a sort of ORM in Java. I am trying to do a static find method that is only in the parent class. Let me get to the point: public class DB { public static Object find (int id) { // i want to return anew instance of the calling subclass } } public class Item extends DB { // nothing here } public class ...

Nhibernate - No Class Mappings!

Why don't I have any class mappings after calling Configuration.Configure()? Here is my class mapping file Category.hbm.xml for BudgetModel.Category: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="BudgetModel" namespace="BudgetModel"> <class name="Category" table="Categories">...

NHibernate - mapping classes that implement multiple interfaces

I am using the Table Per Subclass strategy to persist an inheritance heirarchy: I am running into some confusion as to how to map the Debit class, which implements 2 interfaces. I may be overthinking it; I'm still learning NH. Thanks for any input. EDIT What's confusing me is that the only properties that my concrete classes have, th...

Lazy/Eager loading strategies in remoting cases (JPA)

I'm running into LazyLoading exceptions like the most people who try remoting with an ORM. In most cases switching to eager fetching solves the problem (Lazy Loading / Non atomic queries / Thread safety / n+1 problem ...). But eager fetching has also disadvantages if you are dealing with a really big object graph. Loading the whole ob...

Converting SQL commands to Python's ORM

How would you convert the following codes to Python's ORM such as by SQLalchemy? #1 Putting data to Pg import os, pg, sys, re, psycopg2 #conn = psycopg2.connect("dbname='tkk' host='localhost' port='5432' user='noa' password='123'") conn = psycopg2.connect("dbname=tk user=naa pass...

Making ORM with Python's Storm

The question is based on the thread, since I observed that Storm allows me reuse my SQL-schemas. How can you solve the following error message in Storm? The code is based on Jason's answer and on Storm's manual. import os, pg, sys, re, psycopg2, storm from storm.locals import * from storm import * class Courses(): subject = Unico...

Do I need <class> elements in persistence.xml?

I have very simple persistance.xml file: <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;...

List, Group multiple instances of an object based on ManyToMany field in Django

Given the following models, I need to return a list of Links for each Place, grouped by Category. class Place(models.Model): name = models.CharField(max_length=100) class Category(models.Model): name = models.CharField(max_length=100) description = models.TextField() class Link(models.Model): name = models.CharField(ma...

PreUpdate not firing when adding to a collection

I have a JPA annotated class which contains a collection like so: @Entity public class Employee { @Id private int id; @Basic private String name; @OneToMany @JoinTable(name = "ORG", joinColumns = @JoinColumn(name="MINION"), inverseJoinColumns = @JoinColumn(name="EMP")) private List<Employee> minions = ...

Grails domain class relationship to itself

I need a way to be able to have a domain class to have many of itself. In other words, there is a parent and child relationship. The table I'm working on has data and then a column called "parent_id". If any item has the parent_id set, it is a child of that element. Is there any way in Grails to tell hasMany which field to look at ...

What to use for a flexible data access layer - OLEDB or...?

I am creating a quick and dirty prototype (C#) of an object-relational mapping tool. I would like to support at least two kinds of databases - one will be Microsoft SQL Server 2005/2008 and the other most probably MySQL. Is there any way to use a single data base access mechanism for both database engines and what would it be? Of cour...

How might I set up data plumbing for Silverlight to MySQL in my situation?

In short: What is a good method for setting up read-only data access from Silverlight to a MySQL database? Here are the details of my situation: I'm currently trying to set up a Silverlight application to present data from a MySQL database. Currently, I need to set-up read-only access to the MySQL database (I may set up other tables ...

Maintaining / Auto-generating IBatis SQL Maps?

Hello, I just started a new job and inherited the project from hell. Hell = {2 years over schedule, overly complex, uses both oracle and sql server} There are 100+ stored procedures in the Oracle server and each one has a IBatis SQL Map. Some share the same result map. The DBA likes to change stores procs on a daily basis and not tell m...

What's the best way to make small schema updates with Doctrine/Symfony?

What's the best way to make small schema updates to your symfony/doctrine application? My issue is, I'm working on a new side-project and occasionally find myself adding a new column here, a new column there as i find the need. However, my DB already has existing data and I dont want to run a complete rebuild and drop my DB with the ch...

JPA - Persisting a One to Many relationship

Hi, Maybe this is a stupid question but it's bugging me. I have a bi-directional one to many relationship of Employee to Vehicles. When I persist an Employee in the database for the first time (i.e. it has no assigned ID) I also want its associated Vehicles to be persisted. This works fine for me at the moment, except that my saved V...

Multi-Database Transactional System & ASP.NET MVC

So I have a challenge to build a site that people online can use to interact with organizations.: http://stackoverflow.com/questions/1691058/asp-net-mvc-customer-application One of the requirements is financial processing and accounting. I'm very comfortable using SQL Transactions and stored procedures to do this; i.e. CreateCustomer a...

What's the best strategy to invalidate ORM cache?

We have our ORM pretty nicely coupled with cache, so all our object gets are cached. Currently we invalidate our objects before and after our insert/update/delete of our object. What's your experience? ...

Where IdentityMap belongs: UnitOfWork or Repository?

If I implement some simple OR/M tool, where do I put identity map? Obviously, each Repozitory should have access to its own identity map, so it can register loaded objects (or maybe DataMapper is the one who registers objects in IdentityMap?). And when I commit unit of work, I also need to access the identity map to see which entity is ...

Self-Referential ManyToMany Convention in CakePHP

I have an existing data model where I can rename things freely to match CakePHP's conventions. I have a type of graph node, where a node can have an arbitrary number of child nodes and an arbitrary number of parent nodes (uni-directional relationships). Here's the table of nodes, following CakePHP's conventions: Table: nodes Column: no...

ORM for SQL Scripting

What is the best way to run simple sql scripts in a database (preferably db implementation agnostically)? So, for illustration purposes, using your best/suggested way, i'd like to see a script that creates a few tables with names from an array ['cars_table', 'ice_cream_t'], deletes all elements with id=5 in a table, and does a join betw...