orm

JPA Native Query for Entity with Inheritance

I have an entity class and a subclass based on that entity: @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class A and @Entity public class B extends A I need to issue a native query that uses a stored procedure on the base class (A) only. If I attempt it as follows: entityManager.createNativeQuery("selec...

CodeIgniter, models, and ORM, how to deal with this?

Hello, I'm starting with CodeIgniter and after several hours diving in Google I'm a bit confused. Let's try to explain my question with a easy example: I have a table 'car' with the fields 'name' and 'color'. Therefore I want to have a php class Car, so that my code could look finally like this: $car = new Car('BMW', 'red'); //new $ca...

Is there a way to use Expression.In() in a case insensitive way?

I am using Expression.In() as a part of a criteria using NHibernate and for the life of me I can't find any way to make it ignore case. Does anyone know how this can be done or am I going to have to do this a different way? Not that it probably matters much but here is a sample of how I am using the Expression.In() ICriteria criteria ...

Getting Django Query Count While in manage.py shell

Is there a way to count my queries during a manage.py shell session? It would be helpful as a means to inspect some of the ORM behavior between queries. Additionally, it would be nice to pull the queries themselves, and I guess their execution times while I'm at it. i.e. >>>from myapp.models import User >>>User.objects.filter(...

Lazy-loading with Spring HibernateDaoSupport ?

Greetings I am developing a non-webapplication using Spring+Hibernate. My question is how the HibernateDaoSupport handles lazy-loading , because after a call do DAO , the Session is closed. Take a look at following psuedo-code: DAO is like: CommonDao extends HibernateDaoSupport{ Family getFamilyById(String id); SubFamily getSubFamil...

how does the new keyword in hql work?

I found this example in jboss's documentation. select new Family(mother, mate, offspr) from DomesticCat as mother join mother.mate as mate left join mother.kittens as offspr Where does the Family class come from. Do I need to import somewhere, or to use its fully qualified class name? ...

Is there a generic way of using AutoMapper's ValueResolver to map EntityKey values for EF Entities?

Not sure if the title makes sense, but here's what I'm doing. I'm using AutoMapper to map my Entity Framework Entities to my DTO objects and vice versa. The issue comes when I try to map the DTO data to the EF entity. There's not a property to property mapping for the EntityKey. To fix this, I do some like the following: Mapper....

Writing a SQL generator, What Should I Read Up On?

I am soon going to be writing a component that takes metadata and generates dynamic SQL from it. Mostly we're talking SELECT, INSERT, UPDATE, DELETE stuff but I suppose it's possible to have some CREATE/ALTER TABLE statements in there too. I'm assured that no existing ORM solution fits the bill but otherwise the details on what where a...

Using reserved JPQL keywords with JPA

I have an entity class called "Group" and NetBeans warns me "The entity table name is a reserved Java Persistence QL keyword". A similar case would be the use of reserved SQL keywords. Will this name be escaped? Would the use of a different table name solve the problem @Table(name="otherName"). Or should I rename the class? ...

How do I work around the has_many :through single association restriction?

Given the relations { proposals(id, ...), reviewers(id, ...), comments(id, user_id, proposal_id, ...), votes(id, user_id, proposal_id, ...) } how can I create an association from Vote to Comment? Each reviewer can vote once on a proposal "create unique index on votes(user_id, proposal_id)" and can comment many times. A...

PHP Doctrine toArray problem

I have a problem with the toArray() method in Doctrine. Its doesn't get my relations: First query : $q = Doctrine::getTable('posts')->find(1); debug($q->toArray(true)); Print the postid=1 with out the relations $q = Doctrine::getTable('posts')->find(1); $q->Tags->toArray(); debug($q->toArray(true)); ...prints the results with tag ...

Two Model Classes - One Database Table

Do you ever do this? I'm writing a Rails app. I have a situation where I have a Task model (and table), the Task has attributes, people that are allowed to view it, and a hierarchy (it may be under a project, or a business). I also have an AssignmentController that exposes some views and functionality to the individual that's assigned...

Help with Kohana ORM?

Using the ORM, I want to be able to load all articles that posted, in which a user has made a comment. comments table comment_id user_id article_id etc.... Using ORM, I can access all articles posted by a user, but how would I be able to access all articles in which the user has commented on? Thanks Edit: Another problem is, if a...

Enum in Hibernate, persisting as an enum

In my MySQL database, there's the column "gender enum('male','female')" I've created my enum "com.mydomain.myapp.enums.Gender", and in my Person entity I'm defined "Gender gender". Now I'd want to keep the enum type in my MySQL database, but when I launch my application I get: Wrong column type in MyApp.Person for column Gender. F...

Get children count via HQL

Hi, I have a one-to-many mapping between a parent entity and child entities. Now I need to find the number of children associated with each parent for a list of parents. I am trying to do this with HQL but I am not sure how I can get the list of parents in there. Also, I don't know how I can return the entity itself and not just its ID....

Is there anything wrong with this ORM?

Roughly a month ago (after christmas) i found this post and realized how useful reflection is. So i decided to learn and got carried away and spent around 10days on this which became a ORM for sql(ite). My question is, is there anything wrong with this ORM is used? I never used an ORM before and i heard you should not write one yourself...

Django queries - id vs pk

Hi all, When writing django queries one can use both id/pk as query parameters. Object.objects.get(id=1) Object.objects.get(pk=1) I know that pk stands for Primary Key and is just a shortcut, according to django's documentation. However it is not clear when one should be using id or pk. Thanks! ...

Can the usual ORM solutions interact with OO databases?

For example, can Hibernate handle CouchDb? What about support for other OO databases in other ORM solutions? One of the (not that important) benefits of an ORM solution is the possible ability to swap one database vendor for another. What if you swap a relational database for an object oriented one? [edit] if you feel like giving the ...

Select Disctinct with Friendly ORM

Hi, I'm trying to use the Friendly ORM in combination with Sinatra for a small side project, but I'm having trouble implementing a DISTINCT type pattern. Here is an example of the model class: class Game include Friendly::Document attribute :user_id, Friendly::UUID attribute :friendly_team, String attribute :opposing_team, String a...

data mapper vs active record

What are the advantages and disadvantages of both active record and data mapper? Please be PHP-specific, where the language matters. Personal experiences are welcome! Ideally with both. ...