A long question, please bear with me.
We are using Spring+JPA for a web application. My team is debating over injecting EntityManagerFactory in the GenericDAO(a DAO based on Generics something on the lines provided by APPFUSE, we do not use JpaDaosupport for some reason) over injecting an EntityManager. We are using "application managed...
Consider the following database schema:
create table UserGroup ( id int not null auto_increment, name varchar(200), primary key(id));
create table User ( id int not null auto_increment, name varchar(200), groupId int not null, primary key(id));
User.groupId = UserGroup.id, so a user can only be a member of one group, but a usergroup ...
Hi Gurus,
I have a design/programming question. First I wanna ask if my design is good and then I wanna know how to.
What I wanna do is to have an i18n page, which may or may not have a translation. e.g. Page A has English & Japanese, and Page B may only have English
This is the DB layout
page
----
id int
topic varchar(128)
content v...
Hi,
today I have coded a test case for my application, to see how transactions behave. And I have found that nothing works the way I thought it does.
I have a Spring-based application using Hibernate as JPA provider, backed by MySQL.
I have DAO objects, extending Spring's JpaDaoSupport. These are covered by Spring's transaction managem...
I am building a tool for out-of-container EJB testing. I have managed to run Hibernate's EntityManager in it successfully. Now I want to integrate it with JTA to enable strict control of transactions.
The problem I am faced with is the following: Hibernate seems to require JNDI to work correctly with JBossTS (JBoss's JTA implementation)...
Hi
I have the following class
@Entity
public class Foobar {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
private Organization organization;
private Long orderNr;
}
What I'm trying to do is to create an incrementing order number for this object. The problem is that the order...
I have this entity class, called "Pagina" and I want to update the entry in the database based on the changes made to the entity. This isn't working. I get no errors, but the db is not changed.
@Entity
@Table(name = "PAGINA")
@NamedQueries({@NamedQuery(name = "Pagina.findAll", query = "SELECT p FROM Pagina p"),
@NamedQuery(name = "Pag...
I'd like to configure this mapping with annotations instead of XML.
Here's the mapping config (sanitized for public consumption):
<hibernate-mapping package="com.test.model">
<class name="Parent" table="parent">
<composite-id name="id" class="ParentCompositeKey">
<key-property name="first_id" type="long" column="first_i...
I'm seeing strange behaviour when using PostgreSQL in a Hibernate/JPA environment with a single table inheritance hierarchy.
Firstly my environment:
PostgreSQL 8.3
Spring 2.5.6SEC01
Hibernate-entitymanager 3.4.0.GA (installed from Glassfish update tool)
Hibernate-distribution 3.3.1.GA (installed from Glassfish update tool)
Glassfish V...
Hello Everyone,
I started using groovy intensely to prototype everything. This is amazing.
But I faced the problem with groovy shell.
Next code I run with
groovy filename.groovy
and everything works as expected.
But within groovysh command
load filename.groovy
Doesn't work: it can't find class Book.
The code:
import org.hibern...
I have a TIMESTAMP column on a table that is set to null when a record is initially inserted. I would like to update the value to the current time. My generated entity has a set method for the field as such:
setCloseDate(Timestamp closeDate)
However I do not want to generate/specify the timestamp from java code. Is there any way to...
I've developed a java program that stores entities (using jpa+hibernate) in a mysql database. The entities are users, and other kind of objects. Now I need to write the web side of the application: I need to let user register/login and browse entries that are stored in the db.
I'm new to this kind of programming and I don't know what is ...
I'm using java persistence to save a list of entities that are associated to another entity. Here's a quick rundown of where I'm having some problems.
@Entity public class Offer implements Serializable {
@Id private Long offerId;
@OneToMany
@Column List<OfferCategory> offerCategories;
}
@Entity public class OfferCategory implem...
Hi,
I am trying to write a JPQL query with a like clause:
...LIKE '%:code%'
I would like to have code=4 and find
455
554
646
...
I cannot pass :code = '%value%'
namedQuery.setParameter("%" + this.value + "%");
because in another place I need :value not wrapped by the % chars. Any help?
Thank you
...
Although I'm a fan of using annotations, I do have concern over the dependencies they create on third party jars.
For the purpose of this question, I'm referring specifically to Hibernate or JPA annotations on domain model classes.
In reality, I want my domain model to consist of simple POJOs without any dependencies on a persistence ...
Does anyone have a list of the changes between JPA 1 and JPA 2?
I have read about the Criteria queries and other changes, but I would like a "what's new" kind of reference.
Thanks
...
Hello,
I have an Article entity and an ArticleCode entity. Aritcle Code has Article as forgeing key but is has also a second and third primary key.
The example below isnt possible because Article isnt serializable. Any ideas?
Thanks,
Ralph
@Entity
public class Article {
@Id
@GeneratedValue(strategy=GenerationType.TABLE)
p...
What column does DISTINCT work with in JPA and is it possible to change it?
Here's an example JPA query using DISTINCT:
select DISTINCT c from Customer c
Which doesn't make a lot of sense - what column is the distinct based on? Is it specified on the Entity as an annotation because I couldn't find one?
I would like to specify the co...
I have a bunch of annotated, interrelated POJOs that I want to create/modify/search over SOAP. I made a utility to eagerly load every detail of each POJO and create an XML string so I can send the entire POJO graph as a search result. Even though the graphs are very small (less than three nodes), the eager loading took a very long time...
Hello everybody,
I need to compare two dates in a JPQL query but it doesn't work.
Here is my query:
Query query = em.createQuery("SELECT h FROM PositionHistoric h, SeoDate d WHERE h.primaryKey.siteDb = :site AND h.primaryKey.engineDb = :engine AND h.primaryKey.keywordDb = :keyword AND h.date = d AND d.date <= :date ORDER BY h.date DES...