Is there a way to automatically create javax.persistence.Entity classes from an existing database (or from the SQL statements that created them)?
I am just reading through the persistence part of The Java EE 5 Tutorial and creating all these annotations by hand seems rather wasteful considering that all (or most) of the necessary knowle...
Is it possible to use PESIMISTIC lock option using Spring JpaTemplate methods?
I know that PESIMISTIC lock can be performed using EntityManager's methods e.g.
Account acc = em.find(Account.class, 123);
em.lock(acc, PESIMISTIC);
...
Hi
I am new to Java EE. I tried to get some first examples running (JPA).
I am using Glassfish v3. The trouble is that I don't get the App Server injecting
the EntityManager. Hear is one example http://www.adam-bien.com/roller/abien/entry/ejb_3_persistence_jpa_for
which I extended with a JSP client.
Entity:
package beans;
import ...
my entity class is annotated with @Cache, my primary keys are combined of few table fields, primary keys are embedded into this class as embedded class. Do I need to put @Cache for the embedded class as well?
...
Hy guys,
I am working on a project developed in JEE 5 environment. I want to know how I can declare a Hibernate event listener so that I can be informed when CRUD operation are performed.
I've read that I must declare in the Hibernate configuration file *cfg.xml something like this:
<hibernate-configuration>
<session-factory>
...
Hey,
I've got an excpetion when I generate this EJB SQL Statement.
Exception Description: Syntax error parsing the query [SELECT h FROM Busmodul h WHERE LOWER(h.modulNummer) LIKE :modulnummer AND h.einbauort.id = :einbauort_fk AND h.plattform.id = :plattform_fk ORDER BY TRIM(TRAILING '-' FROM CONCAT('0', h.modulNummer))], line 1, c...
I'm using the EclipseLink implementation of the JPA 2.0 which allows pessimistic locking. I know how to lock an entity but how do I release the lock? At first I thought this was all taken care of within a transaction (in other words, the entity is locked until you commit the transaction), but that does not seem to be the case.
I tried...
Is it possible to access the SQL which is generated by JPQL?
I would like to use the SQL to later create a view for my purposes.
I am using Hibernate if it matters.
...
Hi, I would like to know if there is any way I can store a fileAttachment directly into the database with JPA.
I have an attribute:
public fileAttachement logo;
I have tried to change it to:
@Lob
public byte[] logo;
But that's not doing what I was expecting.
...
I've got the following situation:
A User object has a Set of Permission objects (Set)
Each User can have zero or more Permissions
A Permission object has three fields
The three fields of Permission up make up the composite key for that permission.
As a consequence of this, we want exactly one instance in the DB of each Permission.
...
I have parametrized persistence.xml. I am trying to generate ddl schema using hbm2ddl. How can i pass parameters to this tool ?
My persistence.xml looks like
<property name="hibernate.connection.driver_class" value="${persistence.connection.driver.class}"/>
<property name="hibernate.dialect" value="${persistence.dialect}"/>
<property n...
I'm using JPA in my DAOs outside of Spring . The Spring framework defines DataAccessExceptions that are independent of databases implementations. Is there any advantage for a non Spring user to use the Spring data access exceptions instead of those of JPA ?
I guess that the Spring DataAccessExceptions exist since Spring handle several u...
Hello,
I'm trying to put my named queries in my orm.xml (put in META-INF with persistence.xml) but my orm.xml seems to be ignored by hibernate/jpa.
When I try to create my named query with em.createNamedQuery("myQuery"), it returns that it can't find this query.
I use annotation and I would like to externalize my named queries in orm...
Hello!
I want to output the SQL generated by EclipseLink to the console, during development. However, I could only do so using the logging level FINE. I have a complex domain model composed of many classes, so much that deployment takes a considerable ammount of time when the log verbosity is on the FINE level, since EclipseLink outputs...
I have a JSF 2.0 application that I would like to start adding validators for. A basic overview of the architecture of the app is as follows.
I have Managed Backing Beans that contain instances of my JPA annotated classes and EJB's. The EJB's are responsible for accessing the database transactionally. The JPA annotated classes are value...
We're using OSGI and want to write a JUnit Systemtest. We have one component, that interacts with the database using the Java Persistence API (JPA). When we're launching the test, we get an error message, that the database component couldn't be activated.
We think, that this error occurs, because jpa doesn't find the persistence.xml. B...
I have used the following id generation strategy for primary keys.
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false, insertable = false, updatable = false)
private Integer id;
I would like to do the same for a non primary key column.
[a] What would be th...
I have seen a couple of question regarding creating datasets in DbUnit here on StackOverflow, but all of them were regarding export data from existing tables.
My question is, can DBUnit create some dummy dataset basing on my database schema? I don't care whether the strings would be like "ZDSFFDSDGF" and BLOBS would be just garbage. I j...
Hi,
Can anybody help me in converting the following native query into a Named Query?
Native Query:
SELECT
usr1.user_id, urr1.role_id, usr2.user_id, urr2.role_id, usr1.school_id,
term.term_name, count(material.material_id) as "Total Book Count",
fpc.FOLLETT_PENDING_COUNT as "Follett Pending Count",
rrc.RESO...
What is the best way to express range constraint in JPA? I would like to express something like 'this column can only take values between 1..5'.
Probably I could use @PrePersist and @PreUpdate for that.
Is there a better way?
...