I have a Java enterprise application that provides a web service, has a domain layer, and a hibernate persistence layer. In this particular case, there is not a huge difference (at the moment) between the objects I send over the wire, the domain objects, and the persistence objects.
Currently the application uses DTO's on the persis...
This sounds like a simple task.
Get UTC timestamp value from DB and pass it as UTC date via Web Service.
We have timestamp column DATE_COLUMN and store there time in UTC time zone.
With JPA we get this time with
@Column(name = "DATE_COLUMN")
private java.sql.Timestamp dateValue;
And as we have to pass this time via Web Service in U...
My application is trying to use Hibernate annotations. I've gotten the 3.5.0 version of Hibernate installed, but when I try to load my app I get the following exception:
junit.framework.AssertionFailedError: Exception in constructor: testSubscriber (java.lang.NoClassDefFoundError: javax/persistence/spi/ProviderUtil
at java.lang.Clas...
I have a simple data model in JPA (hibernate) consisting of many to one and one to one relationships similar to this:
town -> state -> governor -> nation -> continent
where town is many to one to state, state is one to one to governor, governor is many to one to nation and nation is many to one to continent.
I would like to fetch a si...
Today I faced an interesting issue. I've been having an inheritance hierarchy with Hibernate JPA, with SINGLE_TABLE strategy. Later, I added a superclass to the hierarchy, which defined TABLE_PER_CLASS strategy. The result was that the whole hierarchy stared behaving as TABLE_PER_CLASS. This, of course, seems fair, if we read the @Inheri...
The following JPA column definition generates an "integer" data type by default on all databases (e.g. h2, mysql, postgres)
@Column(name = "type", nullable = false)
@Type(type = "com.mycompany.hibernate.usertype.GenericEnumUserType", parameters = {
@Parameter(name = "enumClass", value = "com.mycompany.model.DegreeType"),
...
A couple of questions:
If I have mapped a Customer with an i-var List<Order> orders with annotation CascadeType.ALL, should I also set the relation in MySQL InnoDB ON DELETE CASCADE? Or will these interfer?
Is it necessary to say <%@page contentType="text/html" pageEncoding="UTF-8"%> in every JSP file? Can I set this as a configuration...
Hi,
what I would like to accomplish is the following:
have autocommit enabled so per default all queries get commited
if there is a @Transactional on a method, it overrides the autocommit and encloses all queries into a single transaction, thus overriding the autocommit
if there is a @Transactional method that calls other @Transaction...
Hi,
is there a way to reference a .properties file in a spring-context.xml and a JPA persistence.xml?
I think I've seen somewhere an example of this in spring context files, though I can't remember where that was. Maybe someone knows this?
About the persistence.xml I am actually unsure if this works at all.
My aim is to change some pr...
@Entity
public class Person {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private int salary;
@Version
private long version;
// ...getters and setters
}
may i know is there required to create set/get for "version" ?
in my code ,when persist (saveorupdate) this entity with hiber...
I am enforcing a unique constraint check in JPA for userid column which is enforced for all records in the user table.
@Table(name = "user",
uniqueConstraints = @UniqueConstraint(columnNames = userid))
My requirement is that, the userid's within a particular organization needs to be unique and not across all organizations.
How...
Campus has @OneToMany Buildings Building has @OneToMany Rooms.
Room names needs to be unique within a campus
(e.g. campus-A, block-A, room-A and campus-B, block-A, room-A should be possible to store)
Would it be possible to define such a unique constraint on the Room entity?
...
I wonder how JPA defines to handle following scenario:
Table A: | Table B:
ID FK_B | ID
1 10 | 10
2 null | 12
3 11 |
I want all Table A entries with FK_B NULL or referencing not available Table B entry.
public class A implements Serializable {
@Id
private Long id;
@JoinColumn(name = "FK_B", nullable = true)
...
I have a working persistence definition that works on java level tests. Now I want to incorporate that into a web application which defines the database connection as JNDI in the context.xml. What do I need to change to make it work with the JNDI instead of the persistence.xml or at least get the infor from there?
...
I loaded same entity record on 2 separate browser window then press submit (hibernate template.merge), version number incremented for both browser window, but never caught any problem with optimistic lock.. so how to test this?
my save() look like this
hibernatetemplate().merge(..);
setJPAObject(null); //reset after save
...
Hi!
I am working on a simple ejb module, sample code where i am trying to implement CURD operation through a SOAP webservice. My problem is like this. I have a persistence unit defined in persistence.xml file.
Here is the code for my implementation. The problem is that I cannot create the instance of PersistenceService class since, th...
I am hitting an issue with my Hibernate backed Jpa queries returning data that is not up to date. I assume it is an issue with pulling data from the cache instead of the database itself.
For example, I will change and persist an object on one page and then go back to the previous page, which lists rows of the database, and it will show ...
This is a design pattern question, so I'll illustrate it with a simple example of an address book app.
Firstly a few assumptions.
1. It appears to be acceptable to directly use DB domain objects as the backing store for Spring MVC forms.
Iteration 1 of my app I created a JPA mapped Person object with various attributes attached. Using ...
Hello,
I try to build simple Java EE application that uses JPA + EJB3 and Stripes.
It's a little address book. I'm using 2 JPA entities, Person and Email. Every person can have more emails, but each email can only belong to one person. My entities looks like this (with default setters and getters):
Person.java:
@Entity
public class Per...
Hi,
In my DAO implementation I'm doing Stripersist.getEntityManager().persist(client);, this doesn't seem to return any errors, but I can't find the data that it persists.
My client object looks like this :
@Entity
public class Client implements Serializable
{
@Id
@GeneratedValue
private Integer id;
@Column
priva...