orm

When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying

A colleague of mine is currently designing SQL queries like the one below to produce reports, which are displayed in excel files through an external data query. At present, only reporting processes on the DB are required (no CRUD operations). I am trying to convince him that it would be better to use a ruby ORM in order to be able to di...

Column-level UTF-8 in Doctrine

Does Doctrine support setting individual columns to charset UTF8? Documentation seems to refer to table-level only. Please advise. Thanks. ...

Simple modeling of existing SQL Server database schema in Python

I'm looking to write a few small tools for managing table content for an existing SQL Server 2005 DB. I have a few dozen tables of reference content for an application that is deployed on many client databases (often for different schema versions) and I want to build a few python scripts to export, import, diff, and merge this content ac...

Problem with getting ID after inserting a record that has relation in Doctrine

Problem was solved check my answer Hi, I'm having a trouble with getting the id after inserting a new Record using PHP Doctrine Project. In inserting a new record in a table with no parent table (no foreign key) no problem happens. But when inserting a related record here comes the problem, that I get only the parent id which is use...

Can't stop Hibernate from writing log to console (log4j.properties is ok)

I've already set <property name="show_sql">false</property> & disable all messages in log4j.properties But Hibernate shit to console with all queries & statements. ...

IllegalArgumentException: argument type mismatch in Hibernate

Out of the blue I started getting “IllegalArgumentException: argument type mismatch” in hibernate. The hibernate entity was working for quite some time and svn logs confirm the code to be intact. What might be the case? Here’s part of the exception Jan 16, 2010 10:47:09 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE...

CF9 ORM mapping issue DB error

I am trying to map some ORM entities and properties and what should seem right, I get the following SQL error: java.sql.SQLException: Error on rename of './reflexgym/user' to './reflexgym/#sql2-36b-30' (errno: 152) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLErro...

How do I model relative scores between entities in CoreData

I am new to CoreData and am struggling to work out the correct way to model a particular relationship. I have an entity called 'Friend' with a few attributes such as 'name', 'age', 'sex' etc. I would like to be able to model a score between two instances of Friend and am having trouble getting my head around the best way to do this. Fo...

Best way to update some fields of a detached object on Hibernate?

Hi All, I was wondering what's the best way to update some fields of a dettached object using HB on Java. Specially when the object has child objects attributes. For Example (annotations removed and fields number reduced to reduce noise): public class Parent { int id; String field2; ... Child child; } public class Child { ...

Hibernate: Check if object exists/changed

Assuming I have an object Person with long id String firstName String lastName String address Then I'm generating a Person-object somewhere in my application. Now I'd like to check if the person exists in the database (= firstname/lastname-combination is in the database). If not => insert it. If yes, check, if the address is the same....

SQLAlchemy Column to Row Transformation and vice versa -- is it possible?

I'm looking for a SQLAlchemy only solution for converting a dict received from a form submission into a series of rows in the database, one for each field submitted. This is to handle preferences and settings that vary widely across applications. But, it's very likely applicable to creating pivot table like functionality. I've seen th...

Theory about Object Relation Mapping methodlogy

Are there any books or theory how orm systems should be designed or how they should be architecturaly designed .I want to give these to a fresh developer so that they can understand the internals of what they are working with. ...

Is it a missing implementation with JPA implementation of hibernate??

Hi all, On my way in understanding the transaction-type attribute of persistence.xml, i came across an issue / discrepency between hibernate-core and JPA-hibernate which looks weird. I am not pretty sure whether it is a missing implementation with JPA of hibernate. Let me post the comparison between the outcome of JPA implementation ...

Doctrine - How to print out the real sql, not just the prepared statment?

We're using Doctrine, a PHP ORM. I am creating a query like this: $q = Doctrine_Query::create()->select('id')->from('MyTable'); and then in the function I'm adding in various where clauses and things as appropriate, like this $q->where('normalisedname = ? OR name = ?', array($string, $originalString)); Later on, before execute()-in...

@OneToMany without inverse relationship and without a join table?

This is a similar problem to "Hibernate @OneToMany without a separate join table", in that I need a @OneToMany relationship without a join table. However, I would also like to not define the inverse relationship. Removing the inverse seems to result in a join table being automatically generated... is there a workaround for this? ...

Hibernate: How to remove an entity to which none refers to anymore in ManyToOne?

I have two entities, lets call them A and B, which have a ManyToOne mapping to another entity, say C So I typically have something like this: a1->c a2->c b1->c Lots of A's and B's pointing to the same C. How do I get Hibernate to remove c when I remove the last a and b? ...

Filtering only on Annotations in Django

Taking the example from: http://docs.djangoproject.com/en/dev/topics/db/aggregation/#filter-and-exclude Publisher.objects.filter(book__rating__gt=3.0).annotate(num_books=Count('book')) Is there anyway to have the filter only apply to the annotation, so it would return all publishers, with some having a num_books=0? ...

Doctrine - Can I use real SQL (not DQL) in a ->andWhere() ?

I'm using Doctrine, a PHP ORM. I have created a Doctrine Query, and I need more control. So I've started to use the ->andWhere(...) methods to add new where clauses. However I need to do a subquery based on another table, like so: $query->andWhere("id in (SELECT id from other_table where value = ?)", $myvar); The above doesn't work. H...

I found JPA, or alike, don't encourage DAO pattern

I found JPA, or alike, don't encourage DAO pattern. I don't know, but I feel like that, especially with server managed JTA managers. After adequate hands-on using DAO pattern, I started designing JPA based application around that pattern. But it doesn't fit in, IMO. I tend to lose quite a features of JPA and all. Well, suppose you fire...

Doctrine ORM - PHP - Zero Returned Values

I had doctrine and ORM working very well together. Then I removed three rows from my MySQL db and removed those values from my model. Now doctrine returns absolutely nothing. Not even a NULL value from the function or an error. I'm wondering if doctrine caches my schema somewhere or if I'm missing something ...