orm

server is not reading the updated data from database

Describing .... our client updates the database. Then the Hibernate database updated, server should read the updated value from database at that moment. But its not happening. To read the updated value from the database, I have to restart the server. Then I see the updated values. What is happenning? ...

Hibernate annotations @ManyToMany

Hi, I created tables in MySQL: role tabel , object_label and role_object_label (links table) I defined @ManyToMany and I gets exception. what the problem in my code? @Entity @Table(name = "object_label") public class ObjectLabel implements Serializable { private static final long serialVersionUID = 3475812350796110403L; priv...

CriteriaBuilder JPA 2.0 Eclipselink

If I want something like that with EclipseLink and JPA 2.0 SELECT ... FROM ... WHERE name1=value1 AND name2=value2 OR name3=value3 Which is the best way?? In the oficial say somthing like: cq.where(cb.equal(pet.get(Pet_.name), "Fido") .and(cb.equal(pet.get(Pet_.color), "brown"); http://download.oracle.com/javaee/6/tutorial/doc/...

Is it possible to dynamically define column names in Hibernate / JPA?

So i have this existing DB schema with a number of tables that i want to model with JPA/Hibernate. Each table has the same group of 30 additional columns ( to allow for runtime expansion of the number of fields recorded). CREATE TABLE XX ( "ID" VARCHAR2(100 BYTE) NOT NULL ENABLE, "USER_LABEL" VARCHAR2(256 BYTE),...

Django QuerySet .defer() problem - bug or feature?

An example is better than a thousand words: In [3]: User.objects.filter(id=19)[0] == User.objects.filter(id=19)[0] Out[3]: True In [4]: User.objects.filter(id=19)[0] == User.objects.filter(id=19).defer('email')[0] Out[4]: False Does it work like this on purpose ? Subquestion: is there any simple way to get a regular mode...

Has anyone used NHydrate ORM?

NHydrate is a lesser-known ORM for .Net - I stumbled across it for the first time yesterday. They have a good amount of information on their Codeplex page, and a several videos that are also quite informative. After reading through the docs and watching some of the videos I feel very curious about this ORM. Model driven development, a...

Storing a JSP HashMap without a mapping table?

Is it possible have two classes Template and TemplateItem, mapping to two database tables template and template_item, where they are joined using a Map<String, TemplateItem>? If so can it be done using annotations? The following results in three tables, ie adds an un-necessary mapping table. @Entity @Table(name = "template") public cl...

Kohana 3 ORM: constructor "after load"

Is there any way in Kohana 3's ORM to run a chunk of code in a model, but only after that model has been loaded from the database? A simple example is a required has_one relationship. ORM::factory('user')->where('name', '=', 'Bob')->find(); Now what if all users have to have some other property, so if Bob doesn't exist, it will hav...

hibernate using annotations or using hibernate configuration files.

I have seen many tutorials where the hibernate is implemented using annotations (basically hibernate annotations or JPA annotations). There are tutorial which mainly focuses on using the hibernate configuration files(hbm.xml files). No use of annotations at all. Now I am little bit confused, which one is better approach ? ...

Is ORM a problem specific to object oriented programming?

Object-Relational Mapping, ORM is a problem that has to be solved in all applications that is implemented in an object oriented programming language and use a relational database. But isn't the problem the same if you are using structs to map relational databases in C? And tuples/records in a functional programming language? Or am I mis...

EJB3 mapped by? whose owning of OR mapping?

Hello everybody i wonder: when can i use mapped by to indicate whose is owing of relationship in one-to -one or one to many - or many to many relationship mapping with EJB3 (JPA) example i have two table A and B table A belong to table B so what i place mapped by for whose table? ...

JPA to retrieve name-value from child table without using model for child

This is something I'd really like to be able to do - resolve names based on id values without fetching the whole child model. Here is an example of what I have, a Table say Employee and a Name_Details table The Employee may look like this Create Table Employee { emp_idinteger not null generated by default as identity; -- generated pk...

Hibernate annotations

Hi, I created a table in MySQL: 'object_label' with columns 'id' and 'name'. I inserted values to this table. In java I created new class -'ObjectLabel': import javax.persistence.*; @Entity @Table(name = "object_label") public class ObjectLabel implements Serializable { private static final long serialVersionUID =...

How to stop session to save onsaved objects during query execution ?

I have problem with session and query execution, please see code below. class A implements Lifecycle{ public boolean onUpdate(Session session){ Query test=session.createQuery("select * from Unknown"); List list=test.list(); B b=new B(); session.save(b); } } class B{ C c; public B(){ ...

Deleting JPA object fails due to foreign key constraints?

Why would the following query fail due to a foreign key constraint? There is no other way for me to delete the associated data that I am aware of. Query query=em.createQuery("DELETE FROM Person"); query.executeUpdate(); em.getTransaction().commit(); The I believe the offending relationship causing the problem is the activationKey fiel...

How do I do a JPQL SubQuery?

It is possible to do the equivalent of this sql query in JPQL? SELECT * FROM COUNTRIES c WHERE COUNTRY_ID IN ( SELECT DISTINCT COUNTRY_ID FROM PORTS p WHERE p.COUNTRY_ID = c.COUNTRY_ID AND STATE = 'A' ) ...

Best ORM for .NET Windows Forms applications?

Which one is the best .NET ORM for using in a Windows Forms application? I like NHibernate, but it seems that NHibernate is mostly used in web applications. ...

JPA: question on impedance mismatch in OneToMany relations

I have a question about JPA-2.0 (provider is Hibernate) relationships and their corresponding management in Java. Let's assume i have a Department and an Employee entity: @Entity public class Department { ... @OneToMany(mappedBy = "department") private Set<Employee> employees = new HashSet<Employee>(); ... } @Entity public clas...

Is there a way to load an object in Hibernate without writing a query or having an ID?

I can persist an object into the DB from Java as such: Table Person: varchar name varchar groupID varchar emailAddress key on (name, groupID) And in Java Person foo = new Person("dhackner", "3"); session.persist(foo); The two arguments make up the key. In this case, name and groupID are the unique key in the DB, and thu...

How can I serve i18n messages from database effectively

I'm using latest versions of Spring Framework and Hibernate. I know how I can create custom version of MessageSource. But what would be best way to serve i18n messages. Because if I query database every time application needs internationalization, it will cause huge amount traffic to database, and often queries will just return same answ...