jpa

Are JPA / Hibernate Exceptions not translated?

I finished a battery of DAO integration tests using JPA/Hibernate and many of them expect exceptions to be thrown. However, I have noticed that Hibernate seems to ignore the nice heirarchy of exceptions provided by the JPA spec and instead always throws the generic PersistenceException that wraps their Hibernate specific exception. Am ...

What datatype in oracle would map to a Java int?

What type in Oracle (10 Express Edition) would be the "same" as a Java int? ...

Eclipse JPA structure view, detail view, and persistence.xml editor not working?

Eclipse has pretty cool JPA Structure and JPA Detail views along with a persistence.xml editor and a JPA perspective. However, I cannot seem to get them to "turn on". I had them all working several months ago, but something must have changed. Any tips as to what secret sauce is needed to get them working again? ...

Saving owned/child objects in Hibernate

I'm having a hard time wrapping my head around the way hibernate objects work. Here's a little chunk of what my model looks like: JobOpening: @ManyToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL) @JoinTable( name="jobOpening_questionSet", joinColumns=@JoinColumn(name="jobOpenings_id"), inverseJoinColumns=@J...

OnetoMany and ManytoMany using Grails and JPA on google app engine

I googled a lot but i find crap documentation about jpa. I had to implement a domain model like cat and dog inherit from animal, and animal has a one to many and a many to many relation. How to do that? ...

Getting changes in one column of an historical table

Hello, I have a table which stores historical data. It's mapped to an Entity with the following fields (I use JPA with Hibernate implementation): @Entity @Table(name="items_historical") public class ItemHistory{ private Integer id; private Date date; @Enumerated(EnumType.ORDINAL) private StatusEnum status @ManyTo...

Strange JPA one-to-many behavior when trying to set the "many" on the "one" entity

I've mapped two entities using JPA (specifically Hibernate). Those entities have a one-to-many relationship (I've simplified for presentation): @Entity public class A { @ManyToOne public B getB() { return b; } } @Entity public Class B { @OneToMany(mappedBy="b") public Set<A> getAs() { return as; } } Now, I'm trying ...

Are there any good ORMs (preferably JPA implementations) that support SQLite (on Android)?

I found a post from a while ago that addresses a similar question but I think it's a bit outdated. I realize implementations of JPA tend to be more on the heavy/dense side, so if you know of any lightweight (non-JPA) ORMs I'll most certainly appreciate your input. I did see the answer about ActiveAndroid in the other post and am curious ...

Using EclipseLink

I am still new to Java and Eclipse and I'm trying to get my application to connect to a database. I think I want to use EclipseLink, but all of the documentation on the matter assumes you already know everything there is to know about everything. I keep getting linked back to this tutorial: http://www.vogella.de/articles/JavaPersistence...

How to read changed values with native query during one transaction? (Spring and JPA)

We have container transaction with Spring and JPA (Hibernate). I need to make an update on a table to "flag" some rows via native statements. Then we insert some rows via EntityManager from JPATemplate to this table. After that, we need to calculate changes in the table via native statement (with Oracle's union and minus, complex groups....

Deleting JPA entity containing @CollectionOfElements throws ConstraintViolationException

I'm trying to delete entities which contain lists of Integer, and I'm getting ConstraintViolationExceptions because of the foreign key on the table generated to hold the integers. It appears that the delete isn't cascading to the mapped collection. I've done quite a bit of searching, but all of the examples I've seen on how to accomplis...

Is JPA expertise transferable to Toplink?

How similar are JPA and Toplink such that expertise in one could carry over to the other? ...

How to disable sql creation for JPA entity classes

We have some JPA entity classes which are currently under development and wouldn't want them as part of the testing cycle. We tried commenting out the relevant entity classes in META-INF\persistence.xml but the hbm2ddl reverse engineering tool still seems to generate SQL for those entities. How do I tell my code to ignore these classes? ...

How can we compute the LAST page with JPA?

I would like to implement pagination in my Servlet/EJB/JPA-Hibernate project, but I can't figure out how only one page from the query and know the number of pages I must display I use setFirstResult(int first) ; setMaxResults(int max) ; and that's working alright, but how can I know how many pages I will have in total? (Hibernate i...

MVC architecture EJB funcionallity

HI would like to understand how do ejbs work in an MVC architecture, what i do not get is: When the web app starts, the system creates an ejb for each record in every table of db or an ejb with all the records of all tables? Thank you very much ...

How to enforce lazy loading of entities on certain conditions

We have an JPA @Entity class (say User) which has a @ManyToOne reference (say Address) loaded using the EAGER option which in turn loads it's own @ManyToOne fields (say Country) in a EAGER fashion. We use the EntityQuery interface to count the list of User's based on a search criteria, during such a load all the @ManyToOne fields which ...

Persistence unit is not persistent

I need persistence unit that creates embedded database which stays persistent after closing EntityManager. This is my PU: <persistence-unit name="hello-jpa" transaction-type="RESOURCE_LOCAL"> <class>hello.jpa.User</class> <properties> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" v...

How do I delete orphan entities using hibernate and JPA on a many-to-many relationship?

I want to delete orphan entities using hibernate and JPA on a many-to-many relationship but all that I found was this atibute the attribute. org.hibernate.annotations.CascadeType.DELETE_ORPHAN ( i.e. @Cascade(value={org.hibernate.annotations.CascadeType.DELETE_ORPHAN) ), which works only for one-to-many relationships. I want to know if ...

Time not entered in mysql ? Java

Hello, I have a datetime field in mysql table and i am using JPA for persisting data but only date goes in database. Time always shows 00:00:00. What should i do? I am not doing any manipulation with Date. All i do is to assign new Date() to a variable and store it in database. What am i doing wrong? ...

Why is an oracle sequence named hibernate_sequence being created with JPA using Hibernate with the Oracle 10g dialect?

All my entities use this type of @Id @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "MYENTITY_SEQ") @SequenceGenerator(name = "MYENTITY_SEQ", sequenceName = "MYENTITY_SEQ") @Column(name = "MYENTITY", nullable = false) private Long id; Or @Id @Column(name = "MYENTITY") I find that an oracle sequence named hibern...