hibernate

Flex/Air : Flex, BlazeDS, Hibernate (Tomcat) and MySQL

Hello, I create a Flex application that works with a browser using a database with the MySQL server that I can create, modify and delete data from a database. The problem I encounter now is that I want to see my program with Adobe AIR (virtual machine). At the display that does not pose a problem. The problem is that air can not reach t...

How do I re-open a Spring session in conjunction with OpenSessionInViewInterceptor

Hello I am using the Spring MVC framework with Hibernate. All of my controllers are using OpenSessionInViewInterceptor. I am getting "could not initialize proxy - the owning Session was closed" errors in my controller's onSubmit() method. I believe this is because Hibernate needs to go back to the database to fetch certain objects whic...

Hibernate: how to specify clustered index annotation

I want to create an annotated class similar to that: @Entity @MappedSuperclass @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class SeriesMonitoringPointsTable { @Id @Column(name = ID, nullable = false) private Long id; public void setId( Long id ) { this.id = id; } } In this class I woul...

When do we use hibernate's session flush against setComplete()

Hello, I've read spring documentation regarding Hibernate's setComplete() method while working with Unit Test Cases. I am confused between setComplete() versus session's flush() method. Both are responsible to make object's state persistent in Database by loading from memory to actual Database. It will be great if somebody can help me t...

Hibernate Mapping - foreign key referencing a composite PK

I need some help in defining the Hibernate annotation for a foreign key referencing a composite PK table. My composite PK table is FqTankType and I have defined it as private FqTankTypeId id; @EmbeddedId @AttributeOverrides( { @AttributeOverride(name = "tankTypeCd", column = @Column(name = "TANK_TYPE_CD", nullable = false...

Hibernate - different behavior on Linux and Windows

I've run into a peculiar problem where a hql query is working as expected on Windows but does not on Linux. Here is the query: select distinct resource from Resource resource , ResourceOrganization ro where (resource.active=true) and (resource.published=true) and ((resource.resourcePublic=true) or ((ro.resource.id=resource.id and r...

basic Hibernate setup question: why is this resulting in one million null objects?

I have two tables: foo (primary key: foo_id) and foo_entry (primary key: foo_entry_id; foreign key: foo_id). Below is my Hibernate config. My problem is, when I call getAttributes() on the FooModel class, I end up with a list of a little over one million null objects. (foo table has ~200 rows, foo_entry has ~10,000). I'm new to ...

Autowiring HibernateInterceptor as Advice

Hi folks, I am trying to use HibernateInterceptor as a Advice and I am trying to autowire it. The code is as follows, @Aspect public class InterceptorAdvice{ private HibernateInterceptor hibernateInterceptor; @Autowired public void setHibernateInterceptor(@Qualifier("hibernateInterceptor") HibernateInterceptor hiber...

Hibernate -> ArrayList cannot be cast to Set

Hello! I have a Java EE application and I use Hibernate. The domain objects, I changed the List / ArrayList to Set / HashSet, because it is better to use Sets. But in my Dao implementation I run into a problem: public Set<Person> getAllPersons() { SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); Session sess ...

Hibernate -> LazyInitializationException with n:m relation

Hello all! I have a problem with Hibernate and the LazyInitializationException. I searched and find a lot of answers, but I can not use them to solve my problem, because I have to say, I am new to Hibernate. I run JUnit tests, in case of the error this one: @Test public void testAddPerson() { Set<Person> persons = service.getAllPe...

How to mix inheritance strategies with JPA annotations and Hibernate?

According to the Hibernate Reference Documentation it should be possible to mix different inheritance mapping strategies when using Hibernate's XML-Metadata: http://docs.jboss.org/hibernate/stable/core/reference/en/html/inheritance.html#inheritance-mixing-tableperclass-tablepersubclass However, the corresponding section of the Hibernate...

Hibernate Left Outer Join problem: path expected on join

I have two tables, something like: Article and ArticleRelevance They have a one to one relationship, and ArticleRelevance is optional, meaning a Article may (or may not) have a ArticleRelevance. I want to select all articles along with the ArticleRelevance details. With traditional SQL, I will do a outer join on the tables, like SEL...

hibernate auto create in-memory hsqldb causes Sequence not found

I'm using hibernate as my jpa provider and want it to create a in-memory hsqldb on startup using: hibernate.hbm2ddl.auto=create But for some reason I get exceptions like below in my logs. Things seems to work otherwise. Is it a hibernate or hsqldb problem? I'm limited to using jpa 1 so I'm using hsqldb 1.8.0.10 and hibernate 3.3.0.SP...

Spring + Hibernate transaction takes 25 seconds doing nothing

I have a Java application using Spring + Hibernate. I have a pretty simple transaction that just recently started to take REALLY long to execute (~25 secs) though it's not making any obscure / complex queries, and according to the log, those 25 seconds are spent within Hiberante's code. The browser just hangs there waiting until it's don...

Why does using a column name directly in HQL only work sometimes?

I have two HQL queries I am using for a quick-and-dirty unit test. The first looks somewhat like this: from Foo where SOME_FOREIGN_KEY = 42 The second looks like this: from Foo as foo inner join foo.Bar as bar where foo.SOME_FOREIGN_KEY = 42 The SOME_FOREIGN_KEY column is not the name of something that Hibernate knows is mapped. ...

NHibernate Inner Join Fetch Only Some Columns ?

Hello Guys, I'm developing an application with nHibernate and MySQL. I have a HQL command that runs every second, and in this command I do a "Inner Join Fetch", like this: "from Order o inner join fetch o.Customer order by o.Date" It's work fine but It fill all properties of "Customer", and I have a lot of columns in DataBase (al...

Hibernate - duplicate column name on session.flush

Using hibernate and Hsqldb - a list of objects are session.merged through a transaction. When session.flush() is called I get a "duplicate column name in column list: x" where x is the first column. The database table has no duplicate columns and I am able to read the data allright. The table does contain a composite primary key which...

delete all items from sorted set in grails

I have a grails project with a class that I can delete no problem when doing it "manually" from the controller. I use the following code. def delete = { def projectInstance = Project.get( params.id ) def employee = projectInstance.employee def projectarray = new ArrayList<Project>(); projectarray += employee.getProjects(...

Hibernate Criteria: Projecting Count with group by clause

I want to execute the following SQL select count(*) as myCount from user group by name; I came up with the following criteria for the same DetachedCriteria.ForClass(typeof(UserDTO)) .setProjections(Projections.ProjectionList() .Add(Projections.rowCount(),"myCount") .Add(Projections....

For TestNG, what is the proper method for pre-populating the data source containing a complex model when it will be queried using Hibernate?

I wish to write tests for our Seam Framework-based web site's internal search engine that uses Hibernate + Lucene indexing (on DB2) for queries. What is the best solution for populating the data source before the TestNG suite is run when the project's data model is quite complex considering entity relationships and field constraints? For...