Hello good people!
i've hit a block once again with hibernate.I've posted numerous times on different aspects of the user and contact management that i've been building.
The sad thing is that i didn't really have the time to play with it and understand it better before actually starting working with it. Sorry but English is not my ...
I'm running into LazyLoading exceptions like the most people who try remoting with an ORM.
In most cases switching to eager fetching solves the problem (Lazy Loading / Non atomic queries / Thread safety / n+1 problem ...). But eager fetching has also disadvantages if you are dealing with a really big object graph.
Loading the whole ob...
How do I setup a basic OneToMany relationship using a List and get Hibernate JPA to manage the sequence index number of the list automagically? Can this be done?
This is my test case (more or less);
@Table(name="Policy_Root")
public class PolicyRoot extends BaseDomainModel {
private List<Policy> policyList = new ArrayList<Policy>(...
I have very simple persistance.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">...
Hi,
we are using Toplink implementation of JPA + Spring + EJB. In one of our EJBs we have something like this:
public void updateUser(long userId, String newName){
User u = em.get(User.class, userId);
u.setName(newName);
// no persist is invoked here
}
So, basically this updateUser method is supposed to update the name of...
I have a JPA annotated class which contains a collection like so:
@Entity
public class Employee {
@Id
private int id;
@Basic
private String name;
@OneToMany
@JoinTable(name = "ORG", joinColumns = @JoinColumn(name="MINION"),
inverseJoinColumns = @JoinColumn(name="EMP"))
private List<Employee> minions = ...
What is best practice for using Database Transactions with Seam when not using EJBs - ie. when deploying Seam as a WAR?
By default Seam JavaBeans support Transactions. I can annotate a method with @Transactional and that will ensure that a transaction is required. Or I can use @Transactional(NEVER) or @Transactional(MANDATORY). What I c...
Below is my entity id's definition and I am using hibernate as the jpa implemention
@Id
@TableGenerator(name="customer_generator",
table="system_sequences",pkColumnName="sequence_name",
valueColumnName="sequence_next_hi_value",initialValue=1,allocationSize=20)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "customer_ge...
Hi,
Maybe this is a stupid question but it's bugging me.
I have a bi-directional one to many relationship of Employee to Vehicles. When I persist an Employee in the database for the first time (i.e. it has no assigned ID) I also want its associated Vehicles to be persisted.
This works fine for me at the moment, except that my saved V...
I have written a very basic and naive oneToMany relationship between a ChatComponent and its Chat Messages like this:
@OneToMany
List<ChatMessage> chatMessages;
This basically works, i.e., doing something like:
ChatMessage chatMessage = vo.toDomainObject();
chatMessage.setDate(new Date());
//Add the message to the chat component
em.g...
I am setting up Hibernate Caching and want to cache certain entities in different regions. For example, some entities can be "stale" for up to 5 minutes, some for an hour, and some (like lookups) won't change for weeks. To facilitate easy config of regions in my code, I'm trying the following:
I created an annotation named @LookupCache ...
I've got a project which requires both Jersey and Hibernate. Problem is they both use incompatible versions of a Jar file (asm.jar) under the covers. I've looked around Google and it appears that it's possible to get Hibernate to use another facility called Javassist, but when I try to follow the instructions it falls flat. I still get ...
Hi All,
I call
entityManager.flush()
got follow excetion.
I am using Hibernate JAP
...
Hi folks,
I want to annotate following structure:
I have this query:
SELECT A.*, BES.*, BES_2.*
INNER JOIN BES ON A.a = BES.a AND A.b = BES.b
INNER JOIN BES AS BES_2 ON A.a = BES_2.a AND A.b = BES_2.b
WHERE (BES.c = N'foo') AND (BES_2.c = N'bar')
I have the entities Job (representing A) and JobEndPoint (representing BES). The Job...
I would like to perform @Range based hibernate validation checks (org.hibernate.validator.RangeValidator) in my JPA entity code. But it seems to modify the generated SQL with this checks which I would like to avoid. (i.e In the range check, I have the current year as the @Range max value which is bound to change every year).
Hence, I ha...
What is the standard way to implement simple update?
Example: we have User with phone number NNNNNN and now we want to set it to YYYYYY.
@PersistenceContext
private EntityManager em;
public void update (User transientUser) {
what should be here?
}
User entity is as simple as possible:
@Entity
@Table (name = "USER")
public clas...
Hi all,
i'm developing a web-application for managing and sharing images and more general media-types at all.
My technology stack is:
Java 6
Spring 2.5x
JPA 1.0
JCR 1.0 with Jackrabbit 1.6.x
ACID-able DB like Derby oder MySQL with InnoDB
Porting to Spring 3.0, JPA 2.0 and JCR 2.0 is in the queue
During deployment i have to provide ...
I'm working on an Spring application with lots of input forms. I'd like to reuse the field length in the UI-form, validation and JPA annotations. Is there an elegant way to solve this. My solution at the moment is, to use constants to declare the length:
public class Person
{
public static final int FIRSTNAME_LENGTH = 25;
@Column...
my primary key entity look like below
@GeneratedValue(strategy= GenerationType.TABLE)
private Long id;
when i run, i get error
could not get or update next value;nested exception is org.hibernate.exception.SQLGrammerException:could not get or update next value
but when i just change to
@GeneratedValue
private Long id;
no error...
In my JSP/HTML files i use the following servlet to get blob-images from the MySQL-database.
<img src="/image?id=1" />
Image servlet
This is mapped to a imageservlet, who:
- gets a stateless session-bean injected
- uses the session-bean to lookup a product, based on the id passed in to the servlet
- streams this image out as the resp...