orm

Problem with LINQ to Entities query using Sum on child object property

Given this query: from s in services select new { s.Id, s.DateTime, Class = s.Class.Name, s.Location, s.Price, HeadCount = s.Reservations.Sum(r => r.PartySize), // problem here. r.PartySize is int s.MaxSeats } If the service doesn't have any reservations, this exception is thrown: System.InvalidOperatio...

How to get all the element from JDBC query

HI, I have query like this final Query contractQuery = cgnDao.getEntityManager(). createNativeQuery("SELECT k.phrase, ak.type FROM key k INNER JOIN adkey ak USING (key_id) WHERE pck.pub_id =" + pid +" AND pck.c_id =" + campId ); How can i get each and every element from the query? Where phrase is an String and type is...

How to Oracle XMLTYPE in Hibernate

One of the column is of the type XMLTYPE in Oracle database. In my application, I want to persist the data and using Hibernate. I did the following for mapping XMLTYPE in hibernate Define the custom user type implementing UserType The custom user type implementation is based on the blog link - http://community.jboss.org/wiki/MappingOr...

Django ManyToMany relationship with abstract base - not possible, but is there a better way?

Given the following models: class BaseMachine(models.Model) fqdn = models.CharField(max_length=150) cpus = models.IntegerField() memory = models.IntegerField() class Meta: abstract = True class PhysicalMachine(BaseMachine) location = models.CharField(max_length=150) class VirtualMachine(BaseMachine) h...

Deep copying of EJB Entity beans with relations

What I have is an entity bean e.g. Entity (EJB 3) that keeps same type children in an ArrayList<Entity>, his parent <Entity> and a relation to another entity <Users>. Users can own many Entities, and vice-versa (many to many). What I would like to do is override Entity.clone() (or have a new method) to deep-copy Entity along with clone...

.Net ORM bulk deletion via predicate

Is there an ORM that will allow me to do the following? db.Delete<MyEntity>(x => ***some predicate***); We use NHibernate and I don't believe this is possible with it. ...

Is Data Mapper a more modern trend than Active Record

I've come across a couple of ORMs that recently announced they are planning to move their implementation from Active Record to Data Mapper. My knowledge of this subject is very limited. So a question for those who know better, is Data Mapper newer than Active Record? Was it around when the Active Record movement started? How do the two r...

How to make hbm2ddl schemaExport to log schema to stdout?

A quote from persistence.xml: <persistence-unit name="test" transaction-type="RESOURCE_LOCAL"> <properties> <property name="hibernate.archive.autodetection" value="class" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.format_sql" value="true" /> <property name="hibern...

How to use the CURRENT_DATE function in a hibernate criterion?

I want to translate the following HQL into Criteria notation: from Deal where CURRENT_DATE between startDate and endDate I tried using Restrictions.between but it doesn't recognize current_date Criteria c = session().createCriteria(Deal.class) .add(Restrictions.between("CURRENT_DATE", "startDate", "endDate"); ...

Netbeans wizard to generate php classes

Hello. I want a wizard where I insert the database connection, and with some settings it generates the PHP classes. The wizard can use (internally) a template already created. Is that posible? Does that already exists? If not, any ideas of how to do it? Thanks! Edit I'm looking for something wich let me make my own class template or...

what is the difference between Hibernate.initialize and eager fetching

Why I can't use EAGER fetching for the same purpose ...

Which database patterns (ORM, DAO, Active Record, etc.) to use for small/medium projects?

I writing real estate web site with basic function for choosing and ordering realty. It is small/simple project, but I want to write it in way, so in future I, or other developers, can turn it into medium business app without rewriting it from scratch. So what kind of patterns could you advice me to use for dealing with database? For...

Upgrade Glassfish v2 to JPA 2.0?

Hi, I'm trying to use Hibernate 3.5.5 with Spring HibernateJpaVendorAdapter on Glassfish V2 but I'm getting the following exception when the Spring context is initialised: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getSharedCacheMode()Ljavax/persistence/SharedCacheMode; at org.hibernate.ejb.util.LogHelper....

Can hibernate call return a XML data?

Hi, I would like to know if we call a Java class annotated with hibernate classes. Can we get the data from the table in a XML format? browser give data for id =1 --> Servlet --> hibernate class (with some magic xml functionality) --> returns the data in XML format(Can this really happen?) Thanks, Sana. ...

JPA/EclipseLink - Calculated column

Hi, I'm trying to learn JPA. I created a simple entity class. This entity has 3 columns: ID, NAME, NUMBER_A. It's working fine: I can persist, update and delete without problems. What I'm trying to do is to create a calculated/computed column. I want to retrieve NUMBER_A, use it to calculate a new value and set the calculated column (l...

Mixing Zend_Db with ORM Classes

Zend has Zend_Db but it's not a full ORM. I already have sections of an app written in a way that uses Zend_Db. I do however want to integrate a full ORM into the application to use it for more complex database operations, but I don't want to have to re-write existing actions that are complete. Those more experienced with Zend Framework...

Why the value of the foreign key is always zero?

Hi! I try to build some application using hibernate for persistence (my first one). The application has genres and books. The genre class has a set of books. But every book in the set has the idGenre (the foreign key) value 0. I think the mapping is not right. Please tell me where is the mistake. Thanks. Here is the mapping: <hibernat...

Mapping same class relation - continuation

This post is an continuation of this post I have DlUser Class each object of this class may have DLFaceBook class and each object of DlFaceBook can have Friends which are mapped as myFriends. I'm trying to map relation of the same class as many to many relation using bag mapping,composite primary key and static inner class. my code is...

How to define alpha or alphanumeric rules for a ORM model using Kohana 3?

I'm doing this in my model.... protected $_rules = array( 'id' => array( 'not_empty' => NULL, 'numeric' => array(TRUE) ) .... Am I doing it right for the numeric qualifier? Thanks. ...

NHibernate - Many To One - NHibernate.LazyInitializationException - Could not initialize proxy

I am getting this exception when I attempt to access an object that is stored in a property of my domain object. I have done some research and still do not understand why I am getting this error. I have a very basic repository in which I am creating a session and then using a ICriteria query to fetch the first record from the list of r...