orm

SqlResultSetMapping with self join table

I have a query with a self join that looks like this, select t1., t2. from table t1 left outer join table t2 on t2.LFT < t1.LFT and t2.RGT > t1.RGT AND t2.REG_CODE_PAR = 'ALL' AND t1.STATUS_CODE = 'A' AND t2.STATUS_CODE = 'A' I'm using @NamedNativeQuery with a result set mapping to get the result. @NamedNativeQuery( name="fin...

@OneToMany does not insert foriegn key in Hibernate+JPA

Hi folks, I am facing some strange issue, I have a user table(use class) and a country table(country class). An user may have N number of countries. Hence, I have added a List of countries in the user class with the getter and setter method. In the table I have made the country_id as foreign key in user table. And, I have a @OneToMany o...

query results are not found in cache

Env: JBoss 5.1, ehcache 2.1.0, hibernate 3.3.x, seam 2.2.0 ehcache.xml (2.1.0 version) contains the following lines, but my query results are not found in cache. Am I supposed to set a cache region for each of the queries which are fired. What am I missing here? <!-- Cache configuration --> <cache name="org.hibernate.cache.UpdateTimest...

Pattern for updating database through a property when using an internal mapping

I've reached a bit of a problem in my app and I'm not sure how best to resolve it. I'm using Linq to Sql and I have a domain object which wraps the Linq object so I don't directly expose Linq objects to my front end. So I have something like: class MyOrder : IOrder { Order _order; // this is the Linq entity public MyOrder(Or...

Hibernate with Annotations and MySQL: Creation Date

Hey folks, I try to save the date of creation of my entity. I have found that approach. I tried to implement it but the date doesn't reach my db-table. import java.io.Serializable; import java.util.Date; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.PrePersist; @Entity public class Project im...

Hibernate and Event based Interaction

Hi, For my persistence framework I am using Hibernate. What I would like to do is the following: Whenever a new row in inserted (or value of a column changed) in a specific DB table, I would like Hibernate to call a specific procedure? How do I handle this in Hibernate? Thanks, Neel ...

SQL Alchemy - How to Delete from a model instance?

Say I get a model instance like this: instance = session.query(MyModel).filter_by(id=1).first() How can I delete that row? Is there a special method to call? ...

JPA Entity Validation

Ok, I'm trying to setup an application in a Java EE Container. I use JPA for persistence and I also use the javax.validation.constraints.* constraints. By default the container validate the entities during the @PrePersist and @PreUpdate lifecycle events and it's good for me, but how do I handle the ConstraintViolationException? I can't...

using multiple table in hibernate, problem with output

I am using following query from A as a,B as b,C as c where a.val='1' and b.val=a.val and c.val=b.val Now if i do follow query.list(); what will be the output? Also if I want to get the output of above query what else I have to do? ...

Infinite Recursion with Jackson JSON and Hibernate JPA issue

When trying to convert a JPA object that has a bi-directional association into JSON, I keep getting org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError) All I found is this thread which basically concludes with recommending to avoid bi-directional associations. Does anyone have an idea for a workaro...

Datamapper "first" method is querying the whole relation

I'm using Datamapper 1.0 with sinatra and sqlite3 as backend. I have some devices, which have multiple locations, and I usually only want the latest location of a device. The problem is that the generated SQL for the above line will query all locations for the device not just the latest one (and a device can have 10-20k locations). Thi...

Hibernate setParamater a class

I am new to Hibernate. I want to create a public Object getById(Class class,long id) function. I tried creating query like: from :nameEntity where id= :id but I'm facing problems when setting parameter for nameEntity. Hibernate doesn't recognize it as a parameter. I used session.createQuery function. Could you please help me? ...

What is the difference between @ManyToOne(optional=false) vs. @Column(nullable=false)

In JPA, I am confused when to use the attribute optional=false and the annotation @column(nullable=false). What is the difference? ...

How to convince an organization to use NHibernate?

I know it's not a "programming" question per-se, but come on guys - give me a break here... I'm working at a large scaled, really slow organization. We recently started a process to decide on a new ORM technology. After looking in various forums, and test-programming with NHibernate, I think it's awesome. Only problem is, I know that...

Is it possible to search for same value on multiple columns with Hibernate Criteria?

I have search query that has many optional parameters and then search word field that searches many columns. Is it possible to use hibernate criteria for this purpose? I need to search many columns with same search word. Example code (what is not working correctly) if(isNotEmpty(searchWord)) { criteria.add(Restrictions.like("descri...

How to write DDL in the criteria API?

Consider the code in http://stackoverflow.com/questions/3333308/how-do-i-delete-all-jpa-entities The documentation here http://download.oracle.com/docs/cd/E17410_01/javaee/6/tutorial/doc/gjitv.html describes only queries. ...

Linq vs MS Enterprise Library DAAB

At work, we just upgraded from VS2005 to 2010. To this point, we've only used sprocs (I guess out of habit more than anything). I've been playing around with Linq (very simple tutorials - nothing major). As my first actual experience with an ORM, I like it. In addition, I've only recently become familiar with the Enterprise Library bloc...

Please suggest one .Net ORM, which supports runtime schema evolution

All RDBMSs support the ALTER TABLE command, which allows administrators to add new columns to tables, or to change the types of existing columns. I am looking for such a runtime schema evolution function in .Net ORM. I have scanned a few ORM frameworks, and I cannot find an intuitive solution to such an evolution. The closest is OpenAc...

super() type functionality on ORM CFC

When I use CF9's ORM feature and generate an explict setter for my ORM CFC, is there anyway to call the default funcitionailty of the ORM CFC after i have done the work needed in the method. For example i am looking for something like this. Obviosuly the code will not run , and super is the wrong concept since the ORM CFC isnt inherting ...

Django : Getting an instace of a model based on a static location

Lets say I have this model class Egg(models.Model): file = FileField(upload_to='media') img = ImageField(upload_to='media') How to get an Egg instance if I only have the file URL string like 'http://example.com/media/spam.tar.gz'? Can I query by this URL?? ...