It turns out that the following example works when using mysql 5.x, however it doesnt when using an oracle 10g database.
Is there a way to define a unique identifier field that is independant of the database technology?
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
private long id;
I have tested this in h...
I'm sure I'm being stupid but I can't seem to figure this one out...
I have two tables:
department( did, name )
employee( eid, first, last, did )
they have corresponding entities JPA managed entites Department and Employee. Employee has a Deparment field, Department doesn't maintain an Employee list. What I want to do though is find a...
Customer Entity (Parent Entity)
@Entity
public class Customer {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
@OneToMany(mappedBy="customer", cascade=CascadeType.ALL)
private List<Facility> facilities;
//Setter and Getter for name and facilities
public void addFacility(Facility facility){...
I have an User Entity class that I'm trying to do password hashing for. I thought that the easiest way to do this would be to create a password field annotated with @Transient and a hashed password field that is set just before the object is persisted with a method annotated with @PrePersist and @PreUpdate.
So I have something like this...
I have a domain object and annotated as follows
@Entity
@Table(name = "REQUEST")
public class Request {
/**
* Unique id for this request
*/
@Id
@GeneratedValue
@Column(name = "EQ_ID")
private long requestId;
/**
*
*/
@Column(name = "EMAIL_ID")
private String emailId;
/**
*
*/
@Column(name = "REQUEST_DATE")
private Date...
I want to use Glassfish and hibernate. I use the Glassfish update tool to add the hibernate libraries.
So I have all needed libraries.
But when I ran my JUnit test I have this exception :
java.lang.RuntimeException: by java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy
Any idea ?
Thanks a lot
...
In a web application using struts2 ejb hibernate, is it possible to tell the application to find or create an entity for a specific persistence-unit name, which is written in persistence.xml file, in the deployment time?
I have two persistence-unit in persistence.xml, and one datasource
(including two "local-tx-datasource") xml file un...
Hi.
We have the following JPQL:
Select distinct sys.ipAddress from SystemLog sys where sys.ipAddress is not null and sys.ipAddress is not empty
And this generates the following mysql statement.
select
distinct systemlog0_.ipAddress as col_0_0_
from
SystemLog systemlog0_
where
(
systemlog0_.ipAddress is not nu...
I have two JPA entities. In fact both are in the same table, but I think it doesn't matter for now.
There is ProductLine and ProductLineVersion. In ProductLine there are many ProductLineVersions. This relation is unidirectional (no ProductLine in ProductLineVersion).
ProductLineVersion has two Ids: PRODUCT_LINE_ID and PRODUCT_LINE_VER...
What's the exact difference between @JoinColumn and @PrimaryKeyJoinColumn?
You use @JoinColumn for columns that are FKs. A typical column could look like (e.g. in a join table with additional attributes):
@ManyToOne
@JoinColumn(name = "...")
private OtherClass oc;
What happens if I promote the column to be a/the PK, too (a.k.a. ident...
I have a JUnit 4 test case with the Spring @Transactional annotation that saves an object, and then attempts to find it. The test case passes when I use this implementation:
@Override
public EventSummary findEventSummaryById(Integer id) {
return em.find(EventSummary.class, id);
}
It fails when I use this implementation (and then c...
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 ...
UPDATE: after posting, I discovered this is a duplicate of this older question.
I have an odd business requirement: my application supports users getting started as "Guests", then later registering to become "Registered" users.
Guests are feature-restricted: they are not allowed to access some functionality that is available once the...
Hi, I have a problem
Tables
sales_2009
sales_2008
sales_2007
And only one class (sales), How change the table at runtime?
...
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 building a project with Stripes, Spring, JPA & Hibernate amd have an object with a many to one child collection. I have set the loading as Lazy
eg.
@OneToMany(cascade = CascadeType.MERGE, mappedBy = "paperOffering", fetch = FetchType.LAZY)
private List<PaperOfferingAssessment> paperOfferingAssessments;
Now I am getting the Lazy...
I try to execute several queries in one DAO-method. Test is FAILED (the data are not updated). Logs without exceptions.
public List<Domain> getNewDomains(final int maxAllowedItems, final Date timestamp) {
return getJpaTemplate().execute(new JpaCallback<List<Domain>>() {
@SuppressWarnings("unchecked")
public List<Do...
Hello,
I am trying to learn JPA with Hibernate and binding it to a GUI built in Netbeans with Beans Binding. It is a application listing dogs. Each dog can have one to many puppies. You can add and delete dogs, and for each dog you can add and delete puppies.
The dogs are displayed in a JList, when the user selects a dog its properties...
My understanding is that with GAE JPA support I cannot:
@ManyToMany
private Set<SSUser> contacts;
protected SSUser(){}
public SSUser(final String userId, final String emailId){
this.userId = userId;
this.emailId = emailId;
contacts = new HashSet<SSUser>();
}
I'm trying to establish a contacts...
Is there any jpa 1.0 fluent api/interface for query building? I'm using openjpa 1.x, so I'm stuck with JPA1.
I found QueryByProxy, but its maven repo is not working properly.
...