How do I delete all JPA entities?
Hello, In my testing code I need to have a blank/empty database at each method. Is there code that would achieve that, to call in the @Before of the test? ...
Hello, In my testing code I need to have a blank/empty database at each method. Is there code that would achieve that, to call in the @Before of the test? ...
Consider the code in http://stackoverflow.com/questions/3333308/how-do-i-delete-all-jpa-entities The documentation here http://download.oracle.com/docs/cd/E17410_01/javaee/6/tutorial/doc/gjitv.html describes only queries. ...
assertEquals(def.getMengs(), exp.getMengs()); fails, reporting: expected: java.util.HashSet<[...so geht die Legende ... ...legend has it ... ]> but was: java.util.HashSet<[...so geht die Legende ... ...legend has it ... ]> Indeed, through the debugger I see that both sets contain only one Meaning with objId = 1 for both. I expected th...
Hi. I'm trying to generate a database schema for my project using hbm2ddl. I'm using JPA 2 annotations to specify how the schema should look like. Right now I'm having some issues with inherited id's. I have an abstract super class, let's call it AbstractSuperClass, which looks like this: @Entity @Inheritance(strategy=InheritanceType....
How to express the exists clause with JPA? ...
Input: valid jpql output: java code using criteria api to achieve same jpql effects. ...
I've read that since version 6.9, Netbeans includes annotation processing support, a feature needed, for instance, to generate JPA 2.0 entities' metamodels. However, I couldn't find any examples or documentation that shows exactly how to do it. Have any of you guys succeed on this? ...
Hello, In Pro JPA 2 (Apress) book, I have seen examples like, EntityManager em; Long count = em.createNamedQuery(countQueryName, Long.class).getSingleResult(); But, the api , hopefully applied to JPA 2.0, shows the syntax as createNamedQuery(String name) Parameters: name - the name of a query defined in metadata with a single p...
I encounter problem with Hibernate EntityManager 3.5.3-Final when it comes to composite predicates. Example (not actual code snippet, but the idea should be clear): CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); Predicate predicate1 = criteriaBuilder.conjunction(); Predicate predicate2 = criteriaBuilder.conjuncti...
Hi Here is my JPA2 / Hibernate definition: Code: @Column(nullable = false) private boolean enabled; In MySql this column is resolved to a bit(1) datatype - which does not work for me. For legacy issues I need to map the boolean to a tinyint not to a bit. But I do not see a possibility to change the default datatype. Is there any? ...
I am wondering if it is possible using annotations to persist the attributes map in the following class using JPA2 public class Example { long id; // .... Map<String, String> attributes = new HashMap<String, String>(); // .... } As we already have a pre existing production database, so ideally the values of attributes ...
As described here, I want to update the user's database by means of catching the exception that occurs when the entity classes don't match. I understand that I could add a catch statement to every db-interface method, but that's error-prone*. Other 'polling methods' are also possible, but they are not interrupt-driven as I want through ...
I would like to better understand the differences between (1) a traditional Multivalued Relationship/Association @Entity -> @OneToMany -> @Entity and (2) the JPA2 Collection of Embeddable (and basic) Types @Entity -> @ElementCollection -> @Embeddable I see the syntactical differences, but wonder whether there are also ...
Hi all, I have taken a look at JPA 2.0 Criteria API, but I found it to be too cumbersome unlike Hibernate Criteria. Is there any good reason to use JPA 2.0 Criteria API rather than using JPA-QL? Thanks for your advise. ...
I am trying to construct queries dynamically, and my next target is add JOIN clauses (I don't know how can I use the API). By now, for example, this code work for me : ... Class baseClass; ... CriteriaBuilder cb = JpaHandle.get().getCriteriaBuilder(); CriteriaQuery cq = cb.createQuery(this.baseClass); Root entity_ = cq.from(this.bas...
As also described here, I'm trying to determine the best way to initialize and update my application's database. I use EclipseLink-JPA2. I distribute a NetBeans platform application. Considered options: use create-tables ddl-generation: The problem with this is that everytime the application runs it will throw exceptions, failing to c...
Once I deploy my application with JPA the user chooses to install it somewhere. Then however the property set as: <property name="javax.persistence.jdbc.url" value="jdbc:derby:db;create=true"/> gets interpreted into the following exception: couldn't create database in \db. Throughout development it used to be the relative path to the ...
I have a standalone Java application that uses EclipseLink 2.0.1. It is configured by a persistence.xml, and then does something like: final EntityManagerFactory emf = Persistence.createEntityManagerFactory("xy"); final EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); .... em.getTransaction().commit(); I want...
The Hibernate EntityManager documentation states, that: You may use a combination of all three together, annotations without JPA programming interfaces and lifecycle, or even pure native Hibernate Core, depending on the business and technical needs of your project. You can at all times fall back to Hibernate native APIs, ...
I have two databases in MSSQL ,and i want to connect to them using JPA2 I have managed to get it working with one . Can some one help me how do i do that? Thanks a Lot. ...