I am using Spring MVC for an application that involved a multilevel back end for management and a customer/member front end. The project was initially started with no framework and simple native JDBC calls for database access.
As the project has grown significantly(as they always do) I have made more significant database calls, sometime...
Today i have new problem with JPA/EJB3. I have 2 table User and Group
with mapping OneToMany (Group One - User Many)
When I use select statement in EJB, for example:
@NamedQuery(name = "Iuser.findAll", query = "SELECT i FROM Iuser i")
a conflict occur, it not know group field I choose where table? (group field in User Table is groupi...
Hi guys,
I've got a table Category and a table TranslatableText. The category is like this
create table Category (
id int not null,
parent_id int default 0,
TranslatableDescriptionId int default 1,
primary key(id));
create table TranslatableText (
id int not null,
lang enum ('NO','EN','FR'),
text mediumtext,
primary ke...
In JPA, you can inject an EntityManager with the @PersistenceContext annotation:
@PersistenceContext
private EntityManager entityManager;
What is the JDO equivalent of this for a PersistenceManager?
@????
private PersistenceManager persistenceManager;
...
we are going to be working with an old database.
so it is very crucial that we do not modify the database/table/schemas under any circumstances (from the reporting modules), and as such i want to setup a persistence-context with some persistence units as read-only (for reporting modules), and some as normal JTA enabled.
we have already ...
I have Hibernate Entities that look something like this (getters and setters left out):
@Entity
public class EntityA {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_id")
private EntityB parent;
}
@Entity
public class EntityB extends SuperEntity {
@OneToMany(mappedBy = "parent")
@Fetch(FetchMode.SUBSE...
At my company we have a database with one table being so big that it was splitted into 3 tables. They all share an ID and the info is NOT normalized so there is info for several entities in the tables, some entities actually have some fields in one table and some fields in the other tables.
There is a new project and they want to use nH...
I'm working with Doctrine2 for the first time, but I think this question is generic enough to not be dependent on a specific ORM.
Should the entities in a Data Mapper pattern be aware - and use - the Mapper?
I have a few specific examples, but they all seem to boil down to the same general question.
If I'm dealing with data from an ...
Hi!
I'm using JPA over Hibernate in my web-app. Here are two entities (only getters are shown):
class Child {
private Parent parent;
@ManyToOne(optional=false)
@JoinColumn(name="parent_id", referencedColumnName="parent_id", nullable=false, updatable=false)
public Parent getParent() {
return parent;
}
}
class Parent {
...
I am new to JPA & Hibernate. After reading some online materials I now understand what Hibernate is and how it can be used with JPA.
Now, I am trying to run this JPA & Hibernate tutorial. I've done everything they mention in this tutorial.
I don't have Oracle DB, only MySQL. So I made some changes to persistence.xml using my understand...
I'm creating an application that creates a Catalog of files. The data of the catalog will be stored in a database through NHibernate, but the actual files are just stored on a file system. I've abstracted the interface to the file system into an interface called IFileSystemAdaptor.
When an object is persisted from the database I need ...
I am trying to edit a table in Postgresql using JPA in Glassfish using EclipseLink. When I insert an entity, it runs fine. But, when I try to edit or remove the same entity, it fails with the following error. Any idea?
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistenc...
Hi,
For the last three days i am learning JPA by various examples, to change my JDBC code to JPA. Every JPA example and tutorial have main method to run it. Of course,
in main method only they defining EntityManager & EntityManagerFactory.
I dont have main method in my web application's server side code. Is that a problem in point of ...
Hello!
I'm trying to implement my own Hibernate NamingStrategy based on the ImprovedNamingStrategy. This is quite nice... only the foreign keys of many-to-many relations are ugly.
Example scenario:
public class Teacher {
@ManyToMany
private Set<Course> courses;
}
public class Course {
@ManyToMany
private Set<Teacher> ...
Hi, I am currently doing small pet project web programming stuff using
ruby. I am new to web programming, MVC, ORM and so on, so lots of hurdles here.
Anyway, I have difficulties using sequel as ORM.
I already have a postgres db running
(created without using sequel whatsoever, just used plain postgresql command) but
don't know wher...
@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 ...
Let's say we are developing an E-Commerce Web application for a small to medium sized business. Let's further assume that the business is likely to scale over time. In other words, the product line will typically grow.
Up to now I have developed n-tier solutions using ADO.NET and stored procedures with the help of the SqlHelper class. F...
Hi,
How to get max value record from table in hibernate, advance in thanks
...
I am using the following model with Django:
class Hit(Model):
image = ForeignKey(Image)
user = ForeignKey(User)
timestamp = DateTimeField(auto_now_add = True)
What I need is basically a list that contains the count of "first hits" (i.e. hits with no earlier timestamp for the same image) for every user to create sort of a r...
If I am just getting a list of users, and I have no intention of updating this list, do I have the option of marking the query as 'read only' somehow?
Reason being, I know most ORM's keep some sort of change tracking on the rows returned. So if I know before hand that I don't need to update anything, was curious if I could tell the ORM...