orm

To cascade or not to cascade? ("object references an unsaved transient instance" error)

Hello, gentlemen! First, I've tried to ask the similar question yesterday (http://stackoverflow.com/questions/3255407/nhibernate-many-to-many-relationship-question-can-select-cant-update), but after a debugging night hopefully I can rephrase a question the better (right?) way. If I am doing something wrong by that - please tell - I'll er...

Creating a new object instance in hibernate using a sql query

I am attempting to create an object in hibernate using a query, which will then be saved back to the table representing the class. Excerpt from hbm.xml file: <class name="MyClass" table="MY_TABLE"> <id column="ID" name="ID"> <generator class="sequence"> <param name="sequence">MY_SEQ</param> </generator> </id> <property colu...

Recommend a lightweight ORM / Active Record Library

I do not mind which pattern is used. I am just looking for something that is: 1) Lightweight 2) Under active development 3) Well documented 4) Supports MySQL Can anyone recommend anything? ...

ADO.NET EF 4 vs. DataSets (of any kind)

Hello, I've been reading updates on Data Sets vs. Other ORM's like ADO.NET Entity Framework, but a lot of them refer to the older version, so with EF 4 as an option today, what is people's opinion for data sets vs. EF 4, which is better, worse? I like EF 4 because: The designer finally works well. The variation of model options (POC...

Hibernate and question nobody asks

Hi All, I have a several questions about hibernate. In many questions here in stackoverflow, several people are saying that hibernate is not a good choise for very complex databases. If we have very complex database, hibernate is not the right choice. It better suits for green field projects, but it is not so good for complex legacy ...

Is checking whether a DataMapper (or other ORM) model is persisted a code smell?

I've found myself starting to leverage checking persistence to get my models to 'work'. It seems convenient and correct to include a persistence check. On the other hand, it feels a little shady, as if I was being overly cautious or breaking the ORM abstraction in a small way. An example might be: class Shipment include DataMapper:Re...

ORM Framework to learn in Preparation for Doctrine 2

i am currently learning Zend Framework 1.10 and intend to use Doctrine 2. however i see to encounter many problems/errors when trying to use the doctrine 2 sandbox. Runtime Exception: Too many arguments Error in Doctrine 2 Sandbox i am wondering if doctrine 2 is not ready, what shld i learn that will be beneficial in preparing me f...

Need help understanding Owning & Inverse side in Doctrine

how can i using common sense, or that objects model the real world understand how doctrine determines which side is owning or inverse and how relationships are uni/bi-directional? say from the doctrine sandbox. 1 user has 1 address. i guess since user owns the house/address, user is the owning side? The owning side of a relationship...

Need help understanding Doctrine one to many

Referencing doctrine reference - one to many unidirectional class User { // ... /** * @ManyToMany(targetEntity="Phonenumber") * @JoinTable(name="users_phonenumbers", * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, * inverseJoinColumns={@JoinColumn(name="phonenumber_id", referencedColumn...

Making sense out of many to many relationships in Doctrine

referencing doctrine reference - association mapping - many to many bidirectional /** @Entity */ class User { // ... /** * @ManyToMany(targetEntity="Group", inversedBy="users") * @JoinTable(name="users_groups", * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, * inverseJoinColumns={@JoinC...

Question about Hibernate session.flush()

I want to inquire about what actually the flush method does in the following case: for (int i = 0; i < myList.size(); i++) { Car c = new Car( car.get(i).getId(),car.get(i).getName() ); getCurrentSession().save(c); if (i % 20 == 0) getCurrentSession().flush(); } Does this means that after the iteration 20, the cache...

Create a custom JPA temporal annotation

I want some of mycoulmns in the JPA entity to take values from database during inserts/updates, i.e from Oracle sys_context, I believe JPA temporal annotation includes database generated timestamps during insert/updates, Is there any way I could create a custom annotation somewhat simailar to this or provide some default values during in...

JPA and toplink create-table on if they don't already exist?

Looks like jpa is something which makes me ask a lot of questions. Having added this <property name="toplink.ddl-generation" value="create-tables"/> my JPA application always creates tables when running, which results in exceptions in case the tables already exist. I would like JPA to check if the tables already exist and if not crea...

How to specify multiple conditions on left join using JPA Criteria API?

I'd like to convert the following SQL query: select * from region_tree country left outer join region_tree region on country.REG_CODE_PAR=region.REG_CODE and region.LFT < country.LFT and region.RGT > country.RGT and region.REG_CODE_PAR = 'ALL' and COUNTRY.STATUS_CODE = 'A' and REGION.STATUS_CODE = 'A into JPA Crtieria ...

Is it possible to dynamically trigger calling of the @PostLoad method only on demand

Env: JBoss Seam, JPA, Hibernate We use the @PostLoad annotation to dynamically initialize some of the transient variables in our @Entity (sometimes this involves looking up the parent entity to initialize status - which is a costly operation). But under certain circumstances, we don't want this @PostLoad to get triggered, since we will...

Hibernate HQL update with a subselect in set clause

Hi all, I'm trying to do an update in hibernate HQL with a subselect in a set clause like: update UserObject set code = (select n.code from SomeUserObject n where n.id = 1000) It isnt working, it is not supported? Thanks Udo ...

Hibernate - encrypted reference by relations on usernames

I was wondering if my idea is possible with hibernate. What I want is that there is one table with usernames and every table wich has a reference to this table has the username encrypted in a column. So the username doesn't stand in normal text but encrypted in every table which have a reference to the user table. So I need something...

JPA and GregorianCalendar

Does JPA 1.0 support mapping of GregorianCalendar? I didn't find anything in JPA 1.0's mapping file specification about GregorianCalendar. What about JPA 2.0? ...

Is it possible to put all output from show_sql in a seperate file?

When developing or running a spring mvc app locally that uses hibernate, it would be nice if I could get the output of all sql to a seperate file. Is this possible? I know there is a hibernate property show_sql but I believe that will just get jumbled together with all other log4j logging info correct? ...

Tips on creating a reusable library

I recently started transforming all tables from our Oracle production into models so I can start using an ORM. I chose Castle Active Record and can really start to see its potential in making my life easier. Since many of the applications I work with utilize the same tables. I figure it would be nice to create a separate library. My thi...