I've JPA entities and need to perform logic with them. Until now a huge static database class did the job. It's ugly because every public interface method had an private equivalent that used the EntityManager, to perform transactions. But I could solve that having a static em too!
However i'm wondering if that's an appropriate design, es...
I'm trying to persist 3 entities (exp,def,meng) in a transaction, and then persist another 2 (def', meng'), where meng' is related to exp.
However, as I attempt to persist meng' eclipselink/jpa2 is being told to:
Call: INSERT INTO EXPRESSION (EXPRESSION, GENDER) VALUES (?, ?)
bind => [exp, null]
which will throw an expession sinc...
Hello,
I'm learning about bean validation. I have created simple form with username and password input fields which are bound through backing bean to model (User) properties username and password. I have marked them with annotation:
@Id
@NotNull(message="Username cannot be empty")
private String username;
@NotNull(message="Password can...
@Entity
public class Person {
@ElementCollection
@CollectionTable(name = "PERSON_LOCATIONS", joinColumns = @JoinColumn(name = "PERSON_ID"))
private List<Location> locations;
[...]
}
@Embeddable
public class Location {
[...]
}
Given the following class structure, when I try to add a new location to the list of ...
This helps in unit testing.
...
Hibernate provides a mechanism to define multi column indexes via the Table. Is there a way to specify this is an ORM agnostic fashion via JPA or JPA2 (e.g. using the javax.persistence.* APIs)
...
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 & ...
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...
Hi all,
Again, I am new to JPA & Hibernation. I am trying to use JPA technology in my web app. With the help of stackoverflow users, I have cleared many errors. With that experience and Confidence, I thought that I can do further myself. But, the current error is something different. I am not able to find it in google itself.
Its somet...
Hello friends,
I am developing an application using SPRING 3.0.4, JPA 2, Hibernate 3.5.5.
I an trying an existing example given on link http://www.javacodegeeks.com/2010/05/jboss-42x-spring-3-jpa-hibernate.html.
only difference is that I am using latest versions of libraries and JBOSS server.
Following is list of my /WEB-INF/lib dire...
Weird stuff... I have happily used EclipseLink / JPA 2 as provider for my persistence unit for a while (with a MySQL RDBMS in the back). I had DDL-drop/create turned off, since I wanted to keep records in the DB and there weren't any changes to the Entities anyway.
Now I've just made some bigger changes to one Entity (adding some attrib...
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...
I have two entities (Dataset and Item), where the first one contains a list of the latter one.
@Entity
class Dataset {
@Id long id;
List<Item> items;
}
@Entity
class Item {
@Id long id;
@Temporal Date date;
String someCriteria;
}
I am now looking for any dataset, which references an item with someCriteria = 'x' as...
Hi All!
I am trying to persist the entity with constraint validation,
when invoke persist - there is constraint that thrown and the caller get EjbTransactionRolledbackException...
so I try to call the validation explicit and throw ConstraintViolationException/RuntimeException and still the caller get EjbTransactionRolledbackException......
I was reading this book. Explaing about "@OneToOne unidirectional", the author has taken the following Customer, Address example:
@Entity
public class Customer{
@Id @GeneratedValue
private Long id;
private String name;
private Address address;
//few other columns, getters/setters
}
@Entity
public class Address{
@Id @G...
Hi all,
I'm getting extremely weird behavior out of JPA 2.0 Criteria API with Hibernate 3.5.1-Final as a provider.
I'm trying to build a dynamic query that looks like this in JPQL:
SELECT e FROM Employee e WHERE lower(e.firstName) like lower(:employeeName) OR lower(e.lastName) like lower(:employeeName)
but keep getting the er...
I have an in-memory data source:
java.sql.Connection c = DriverManager.getConnection("jdbc:hsqldb:mem:testdb", "sa", "");
emf = Persistence.createEntityManagerFactory("manager");
But now I'm stuck. I want to use it as a JPA data source in a J2SE application. I've scoured the entire web but all info is related to J2EE.
<pe...
I am using JPA to insert into Mysql database and it is not able to persist symbols like double quotes(") or euro etc. instead of that it persist Que mark (?)
...
suppose i have the following entity domain:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TYPE")
public abstract class Entity1 {
//some attributes
}
@Entity
@DiscriminatorValue("T1")
public class Entity2 extends Entity1 {
@OneToMany(fetch=FetchType.EAGER, cascade = { CascadeType.ALL }, mapp...
If I'm using an ORM like JPA2 - where I have my entities that are mapped to my database, should I still be using a DAO? It seems like a lot more overhead.
For example, I would need to maintain three extra packages:
One that specifies my domain objects (which pretty much map my Entity objects):
public class Employee {
private Stri...