orm

HSQLDB Constraint Violation & SQL Query Log for an HSQLDB in-memory setup

We have a setup where we are using an embedded HSQLDB for backing Hibernate/JPA unit tests in java, and we are using the in-memory database mode since we simply want the database thrown away after the test run. My problem is that one of the tests is failing due to a constraint violation and HSQLDB lists the column as SYS_CT_286, and the ...

How do you use the LINQ to SQL designer to generate accessor methods for subclasses?

Above is the LINQ to SQL designer view for my data context. Below is the relevant code that the designer generates: Accessor for the abstract ActivityBase class: public System.Data.Linq.Table<ActivityBase> ActivityBases { get { return this.GetTable<ActivityBase>(); ...

Using Hibernate outside the context of Tomcat

Anyone used Hibernate to access a DB in a pure java app (not a web application)? What was your experience like, did it take long to set up and get going? ...

Hibernate criteria -- alias

Hello, I'm struggling a bit with the concept of alias in Hibernate. My situation is the following: Order @OneToMany(cascade=CascadeType.ALL,mappedBy="m_order") private Set<OrderDetail> m_details; OrderDetail @ManyToOne(cascade=CascadeType.ALL) @JoinColumn(name="product_id") private Product m_product; @ManyToOne(casca...

Date query with Hibernate on Timestamp Column in PostgreSQL

A table has timestamp column. A sample value in that could be 2010-03-30 13:42:42. With Hibernate, I am doing a range query Restrictions.between("column-name", fromDate, toDate). The Hibernate mapping for this column is as follows. <property name="orderTimestamp" column="order_timestamp" type="java.util.Date" /> Let's say, I want to...

Using serializable in hibernate what underlying database types do i use.

I need to use a serializable type in hibernate (to store a Subject (security)) All this works fine. I just need to know what the underlying database types are for the following databases: MSSQL - I used 'image' db2 - postgre - mysql - Thanks.. ...

Modeling a Generic Relationship (expressed in C#) in a Database

This is most likely one for all you sexy DBAs out there: How would I effieciently model a relational database whereby I have a field in an "Event" table which defines a "SportType"? This "SportsType" field can hold a link to different sports tables E.g. "FootballEvent", "RubgyEvent", "CricketEvent" and "F1 Event". Each of these Sp...

FieldError when annotating over foreign keys

I have a models file that looks similar to the following: class WithDate(models.Model): addedDate = models.DateTimeField(auto_now_add=True) modifiedDate = models.DateTimeField(auto_now=True) class Meta: abstract = True class Match(WithDate): ... class MatchFilter(django_filters.FilterSet): class Meta: ...

Hibernate Collection chaining

I have two Entities University courses Course students i want to access all the students in a university. I tried the following query select u.courses.students from university u i got the following exception. org.hibernate.QueryException: illegal attempt to dereference collection [university0_.id.courses] with element p...

ORM Persistence by Reachability violates Aggregate Root Boundaries?

Most common ORMs implement persistence by reachability, either as the default object graph change tracking mechanism or an optional. Persistence by reachability means the ORM will check the aggregate roots object graph and determines wether any objects are (also indirectly) reachable that are not stored inside it's identity map (Linq2Sq...

How to use JTA support in Tomcat 6 for Hibernate ?

They recommend using JTA transaction support in JEE environment. But how to configure JTA in Tomcat6 so that Hibernate Session could use it ? Starting with version 3.0.1, Hibernate added the SessionFactory.getCurrentSession() method. Initially, this assumed usage of JTA transactions, where the JTA transaction defined both the scope a...

How do I do a semijoin using SQLAlchemy?

http://en.wikipedia.org/wiki/Relational_algebra#Semijoin Let's say that I have two tables: A and B. I want to make a query that would work similarly to the following SQL statement using the SQLAlchemy orm: SELECT A.* FROM A, B WHERE A.id = B.id AND B.type = 'some type'; The thing is that I'm trying to separate out A and B's logic i...

Detecting modfications in the persistent state

Hi, I know that during a update hibernate cand detect if any change has been done. If it is no, no sql request will be done. IS there a way to get this boolean information computed by hibernate ? Thanks in advance Regards ...

Finding users whose birtday is today with JPA

Hi, I have a table with users and are trying to get a list with the people who have birthday today so the app can send an email. The User is defined as @Entity public class User { @Size(max = 30) @NotNull private String name; [...] @Temporal(TemporalType.DATE) @DateTimeFormat(style = "S-") protected Date ...

Entity persist register validation listener

I'm using JBoss 6 with Seam, and I have an entity I am trying to persist, User. I have extended org.jboss.seam.framework.EntityHome to provide a UserHome class and have overridden the persist() method. I have thoroughly annotated my entity class with javax.validation annotations. When I provide valid values for all the fields in my entit...

How do I share a Hibernate SessionFactory across web applications?

I have two web applications that are running on a single Tomcat server and are connected to the same database with Hibernate. I am concerned that having two SessionFactory instances running around might cause some issues. Also, since both web applications share much of the same application logic, I thought it would be a good idea to cen...

Hibernate not using schema and catalog name in id generation with strategy increment

Hi, I am using the hibernate increment strategy to create my IDs on my entities. @GenericGenerator(name="increment-strategy", strategy="increment") @Id @GeneratedValue(generator="increment=strategy") @Column(name="HDR_ID", unique=true, nullable=false) public int getHdrId(){ return this.hdrId; } The entity has the following table...

Getting fewer columns with hibernate

I have a table with 11 columns, but I need to get only 2 of them in my application, I'm using spring/hibernate/DAO combination. For now I have a domain class which includes all 11 fields, and mapping file which maps all 11 columns in table. How do I use get just 2 of them not all? ...

Hibernate querycount query, dont know how to do

I want to make an hibernate querycount on a table. I have to values, one string and one boolean HibernateUtil.queryCount(VoteOnPublication.class, new String[] {VOTED_PUBLICATION_ID_FIELD, FOR_OR_AGAINST_FIELD}, **********); my voted_publication_id_field is a string, and my for or against field is a boolean. What should i put in my s...

What are the benefits of using ORM over XML Serialization/Deserialization?

I've been reading about NHibernate and Microsoft's Entity Framework to perform Object Relational Mapping against my data access layer. I'm interested in the benefits of having an established framework to perform ORM, but I'm curious as to the performance costs of using it against standard XML Serialization and Deserialization. Right now...