jpa

@OrderBy Issue in Hibernate

I am trying to generate a query using EntityManager.createQuery for my ORM mapping classes. The resulting query's order by included the primary key field of the class by default even though I have specified two fields to order by in @OrderBy (sequenceOrderNo asc, nextXpath asc). Can anyone advise me how to remove the default primary in...

problem in posting data from client side to server side in OnetoOneMapping

In Spring MVC when I submit data from my form then the exception occurs as given below. The situation is like I have Entity class and I have taken another Entity in it as part of relationship. when I send data to display it is working properly but when I post data after editing exception occurs. I have tried initbinding as well but does...

Some basic JPA+Hibernate Questions?

Hi, I have some basic questions: 1) How many xml files involved in JPA+Hibernate combination, if JPA annotations were used? i am having just persistence.xml. 2) Is hibernate.cfg.xml needed, if i use JPA annotaions. Because, i didnt added it till now. 3) Shall anyone give me the list of basic JAR file names, in case of using JPA 2.0 & ...

jndi database connection with jpa and eclipselink

Hi, I try to setup a database connection in java with JNDI in combination with eclipseLink/JPA on Tomcat 5.5. I already configured the JNDI resource in web.xml and context.xml. The db connection works with JNDI without using JPA and eclipseLink. After configuring the persistence.xml for eclipseLink, I got the following exception. I do...

How to define an non-JTA datasource for JPA-Hibernate? org.hibernate.connection.DatasourceConnectionProvider - Could not find datasource:

Hi all, I am trying to change my web-app's JDBC code to JPA using Hibernate as provider. I am using Eclipse IDE. In that i have defined a MySQL data source. I added it in the persistence.xml. But, I am getting the below error. 6640 [30289364@qtp-7494106-7] ERROR org.hibernate.connection.DatasourceConnectionProvider - Could not find da...

spring mvc 3.0 caching

hi, I'm using spring mvc 3.0 with eclipselink and jpa and I'm experiencing following issue: I have this field in my app: @OneToMany(mappedBy = "stadium") private Set<FootballMatch> footballMatches = new HashSet<FootballMatch>(); when there is triggered some action that adds new items into set via Set.add(), the changes doesn't show up...

How to use JDBC ClientInfo with JPA and EJB3

We are migrating a JDBC based application to JPA and EJB3. Our old application used the Connect#setClientInfo API to record the current user name as part of the client info: http://download.oracle.com/javase/6/docs/api/java/sql/Connection.html#setClientInfo%28java.lang.String,%20java.lang.String%29 We need to do something similar in th...

problem in posting data in one to one mapping

i am experiencing problem when my form post data to save to database by jpa where i have used one to one mapping to a class. the there is exception occurs that says that org.springframework.beans.NullValueInNestedPathException: Invalid property 'user' of bean class [org.mkcl.iforum.adnan.domain.UsersCredentials]: Value of nested proper...

Hibernate persistence slow on One-To-Many

I have a quite large object tree structure that I persist with Hibernate. This should have been persisted with the root-node first and then the children and so on. However this was not the way that Hibernate did it, it persisted the child first and than updated the reference column in the child when the parent had been persisted. This is...

I am confused of Hibernate?

I learnt JPA for ORM. Now i am asked to use Hibernate as my provider. If i start with Hibernate it is going down in different concept. Please say me How can i relate JPA and hibernate together. JPA reduces my Java code into simple code for persisting Objects. Now what does hibernate help JPA and what does it provide. Anyone plea...

Enforce FK Constraints when JPA inserts inherited objects

I have a multilevel inheritance model in JPA that is using the joined strategy @Entity @Table(name="PARTY") @Inheritance(strategy=InheritanceType.JOINED) @DiscriminatorColumn(name="PARTY_TYPE",discriminatorType=DiscriminatorType.STRING) public class Party implements Serializable{ ... } @Entity @Table(name="PARTY_ORG") @DiscriminatorVal...

How to add a separate Primary Key to a Join Table in Hibernate

Hi there, I have a question about Hibernate ManyToMany mappings. I have two classes A and B and the mapping between them is a ManyToMany mapping resolved by Hibernate: @Entity @Table(name="A") public class A { @Id @GeneratedValue private Long id; @ManyToMany @JoinTable(name="C", joinColumns=@JoinColumn(name="a_id"...

What Query should i use in Hibernate to fetch POJO?

I learnt Hibernate and used it to reduce my Java code to a vast extent and also able to reduce the time spent for DB's. Now what type of query should i use to finish my operations for getting a DB list to be displayed, to update and delete. My code for deletion is String newToken = "DELETEUSER"; if(!TokenManager.checkRoleToken(newTo...

How do I query for only superclass entities in a jpql query?

I have the following entities: @Entity @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="orderType", discriminatorType=DiscriminatorType.STRING) @DiscriminatorValue(value="BASE") @Table(name = "orders") public class OrderEntity implements Serializable { ... and @Entity @DiscriminatorValue(value="RECURRING...

JPA - disable validation of persistence.xml

I'm taking my first steps with JPA (Hibernate). The overall idea is to connect to a legacy database to do complex queries. I think, hibernate is a great companion for this task, but... ... for a start, I created one bean, the persistence.xml and hibernate.cfg.xml configuration files and some lines of code in a main method, starting with...

Using timestamps causing trouble with WSDL generation

Hi, I have some TIMESTAMP columns in my Oracle database and the JPA entities use java.sql.Timestamp to map them. Using RAD 7, I was trying to generate Web Services for my EJB methods, but it fails with the error: The class java.sql.Timestamp is defined in a java or javax package and cannot be converted into an xml schema type What...

Product creation doesn't work (under Spring MVC with JPA)

Well, the code is working under the Test Enviroment, but not on the front context of the application. This is driving me crazy to be honest. Here is the controller: package org.admios.nuevoproyecto.controller; import java.util.List; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitB...

define jpa entity classes outside of persistence.xml

Is there a way to define jpa entity classes outside of persistence.xml (i.e. in a separate file)? Being able to not have persistence.xml as an external file would also suffice. Thanks in advance, Steven Edit: Sorry I was not clear. This is in a Java SE environment. Also, I would like to not have a listing of some.class.AClass in my pe...

Hibernate creates duplicate entries in the database.

I have a database structure which is something like the one described below. "Universe" can contain any number of "Items". "Person" may have a "Box" which refers to one or more of the "Items" in the "Universe" Universe, Items, Person, Box are all database tables. Box is like a join table for the Person and Items. Note: I am using ja...

How to connect to remote MySQL server via SSH using JPA?

Hello, I'm trying to connect to remote MySQL server via SSH in my Java project. How can I integrate SSH connection with JPA? I'm using Netbeans 6.9.1, JPA, MySQL 5.2. Thanks ...