What would be the easiest way to detach a specific JPA Entity Bean that was acquired through an EntityManager. Alternatively, could I have a query return detached objects in the first place so they would essentially act as 'read only'?
The reason why I want to do this is becuase I want to modify the data within the bean - with in my app...
What are the steps required to enable Hibernate's second-level cache, when using the Java Persistence API (annotated entities)? How do I check that it's working? I'm using JBoss 4.2.2.GA.
From the Hibernate documentation, it seems that I need to enable the cache and specify a cache provider in persistence.xml, like:
<property name="hib...
I have a web application that receives messages through an HTTP interface, e.g.:
http://server/application?source=123&destination=234&text=hello
This request contains the ID of the sender, the ID of the recipient and the text of the message.
This message should be processed like:
finding the matching User object for both th...
I have the following Java 6 code:
Query q = em.createNativeQuery(
"select T.* " +
"from Trip T join Itinerary I on (T.itinerary_id=I.id) " +
"where I.launchDate between :start and :end " +
"or ADDDATE(I.launchDate, I.equipmentPullDayOfTrip) between :start and :end",
"TripResults" );
q.se...
Relating to my earlier question, I want to ensure all the child objects are loaded as I have a multiple threads that may need to access the data (and thus avoid lazy loading exceptions). I understand the way to do this is to use the "fetch" keyword in the query (EJB QL). Like this:
select distinct o from Order o left join fetch o.orde...
i have one applicationContext.xml file, and it has two org.springframework.orm.jpa.JpaTransactionManager (each with its own persistence unit, different databases) configured in a Spring middleware custom application.
i want to use annotation based transactions (@Transactional), to not mess around with TransactionStatus commit, save, and ...
I'm trying to load test data into a test DB during a maven build for integration testing. persistence.xml is being copied to target/test-classes/META-INF/ correctly, but I get this exception when the test is run.
javax.persistence.PersistenceException:
No Persistence provider for
EntityManager named aimDatabase
It looks like it...
Hello,
I'm experiencing the following very annoying behaviour when using JPA entitys in conjunction with Oracle 10g.
Suppose you have the following entity.
@Entity
@Table(name = "T_Order")
public class TOrder implements Serializable {
private static final long serialVersionUID = 2235742302377173533L;
@Id
@GeneratedValue(...
I want to make an entity that has an autogenerated primary key, but also a unique compound key made up of two other fields. How do I do this in JPA?
I want to do this because the primary key should be used as foreign key in another table and making it compound would not be good.
In the following snippet, I need the command and model to ...
My team is about to build a new product and we are using Hibernate/JPA as the persistence mechanism. There are other book posts on stackoverflow, but I couldn't find one that matched my needs.
My manager will be purchasing books for our team to use as a resource so...
What are the best books about Hibernate and JPA?
(Please list each...
I are using EJB 3 on a fairly large J2EE project, by default with Netbeans sets the persistent provider for the entity beans to TopLink. There is the option to change the provider to one of the following or even add a new persistence library:
Hibernate
KODO
OpenJPA
Which persistence provider do you prefer to use? What are the benefit...
Working in a medium size project during last 4 months - we
are using JPA and Spring - I'm quite sure that JPA is not
powerfull for projects that requires more than CRUD
screen... Query interface is poor, Hibernate doesn't
respect JPA spec all the time and lot of times I need to use
hibernate classes, annotations and config.
What do ...
I'm trying to run the Tomcat with JBoss Embedded jpa booking example. I run the build and deploy the war. I then get the following error:
ERROR [catalina.core.ContainerBase.[Catalina].[localhost].[/jboss-seam-jpa]] Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.NoClassDefFoundError: j...
Right now I'm making an extremely simple website- about 5 pages. Question is if it's overkill and worth the time to integrate some sort of database mapping solution or if it would be better to just use plain old JNDI. I'll have maybe a dozen things I need to read/write from the database. I guess I have a basic understanding of these tech...
I came aboard a new project with a new company and we are trying to use JPA to do some DB work. So we have an Ear with an EJB, a webservice, and then there is a app client in the ear that really does all the work. The Webservice, calls the EJB, and the EJB calls the client to do the DB work. So within the appclient I want to load an E...
I have this code:
@PersistenceContext(name="persistence/monkey", unitName="deltaflow-pu")
...
@Stateless
public class GahBean implements GahRemote {
But when I use this:
try{
InitialContext ic = new InitialContext();
System.out.println("Pissing me off * " + ic.lookup("java:comp/env/persistent/monkey"));
Iterator e = ic.getEnvironm...
I have a class Animal and an interface it inherits from IAnimal.
@MappedSuperclass
public class Animal implements Serializable, IAnimal{...}.
@Entity
public class Jaguar extends Animal{...}
My first question is, do I need to annotate the interface?
I asked this because I am getting this error when I run my tests:
Error compiling...
Does anybody know if Hibernate's static initialize() method, which populates a proxy object, will attempt to hit the second-level cache before going to the database? My code seems to be behaving that way, and I can't seem to find anything in the documentation about this. The Javadoc is (as usual) sparse.
Thanks!
...
Hopefully, I can explain this issue properly. I have 3 classes that deals with my entities.
@MappedSuperclass
public abstract class Swab implements ISwab {
...
private Collection<SwabAccounts> accounts;
...
}
@Entity
@Table(name="switches")
@DiscriminatorColumn(name="type")
@DiscriminatorValue(value="DMS500")
public class DmsSwab ...
I have 2 tables:
A
s_id(key) name cli type
B
sa_id(key) s_id user pwd
So in Jpa
I have:
@Entity
class A...{
@OneToMany(fetch=FetchType.EAGER)
@JoinTable( name="A_B",
joinColumns={@JoinColumn(name="a_id", table="a",unique=false)},
inverseJoinColumns={@JoinColumn(name="b_id", table="b", unique=true)} )
Collection getB...