I have a Person entity with multiple phone numbers.
@OneToMany(mappedBy="person", cascade=CascadeType.ALL)
public Set<PhoneNumberOfPerson> getPhoneNumbers() {
return phoneNumbers;
}
Now I would like to implement a "get default phone number" method for Person that is eagerly fetched. This default phone number is one of the phone ...
We have a stock control system which manages the flow of certain items in and out of the business or given location. We have records in the db representing the movement of stock and the inbound and outbound deliveries.
If you were to add up all the inbound deliveries and then the outbound deliveries and subtract one from the other, you ...
Performance is key: Is it better to cascade deletes/updates inside of the Database or let Hibernate/JPA take care of it?
Will this effect the ability to query for the data if cascades are inside of the DBMS?
I am using HSQLDB if that matters.
...
Was thinking about a scenario, suppose two entities, Customer and Order. Suppose I want to see all distinct customers who fulfills a certain criteria, who has one or more orders fulfilling a criteria.
If I use something like:
Select distinct cust from Customer cust join cust.orders order where order.x = 'y' and cust.z = 1
The above ...
Hi all,
I have made use of the following JPA implementations:
Hibernate,
Toplink,
OpenJPA
Each of them has their own strengths and weaknesses. I found Hibernate the most advanced of the three except that it mixed some of its own enhancements with JPA which made it difficult to switch out to other providers. Most importantly, its que...
I am working on a project for a customer who wants to use lazy initialization.
They always get "lazy initialization exception" when mapping classes with the default lazy loading mode.
@JoinTable(name = "join_profilo_funzionalita", joinColumns = {@JoinColumn(name = "profilo_id", referencedColumnName = "profilo_id")}, inverseJoinColumn...
I have a collection of states, that I want to cache for the life of the application, preferably after it is called for the first time. I'm using EclipseLink as my persistence provider. In my EJB3 entity I have the following code:
@Cache
@NamedQueries({
@NamedQuery(
name = "State.findAll",
query = "SELECT s FROM State...
I'd like to store username that has last modified table row to as a field in every table.
I have following setup: an user logs in, web layer calls some EJB 3.0 beans. Those EJB beans create and modify some JPA entities.
Now, I'd like that username (from weblayer) would be automatically stored to every JPA entity (and database row) that...
I have a legacy database, which I am using EJB3 to model. The database is in quite a poor shape, and we have certain unusual restrictions on how we insert into the DB. Now I want to model the database in a hierarchy that fits in with the DB strucuture, but I want to be able to manually insert each entity individually without the persiste...
Using HQL, I would like to search for the starting index of sequenced objects.
For example, if I have the following persisted classes:
<class name="Word">
<id name="id" type="int">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<many-to-one name="sentence" class="Sentence"/>
<property name="...
if I write in HQL
A between 5 and 10
is that equivalent to
A >= 5 and A <= 10
or
A > 5 and A < 10
or some other of the 4 combinations?
...
Where can I find a list of all HQL keywords?
...
I'm using JPA with a postgres DBMS and I'm trying to create a new entity that maps to the table "User".
This is a very common problem as User is a reserved word in Postgres. My question is, how can i "escape" the reserved keyword or set JPA to escape it?
I tried @Table(name = "\"user\"") with no luck:
2009-02-25 15:43:14,218 ERROR...
I have the following entity structure: Business --> Campaign --> Promotion, where ONE Business can have MANY Campaigns and ONE Campaign can have MANY Promotions. Both one-to-many relations are declared as LAZY. One place in my code, I need to eagerly fetch both collections from a Business, so I do:
Query query = entityManager.create...
I have an EJB 3 Entity bean that has a String property annotated with: @Column(unique=true). This value is set from a JSF page.
Everything works fine as long as the user does not add whitespace add the end of the input field. In that case "someName" and "someName____" are treated not unique and are stored in the database. Is there a con...
Is it possible to use hibernate as Glassfish's persistence provider and if so HOW?
...
This question is somewhat related to http://stackoverflow.com/questions/305880/hibernate-annotation-placement-question.
But I want to know which is better? Access via properties or access via fields?
What are the advantages and disadvantages of each?
...
I am persisting objects using JPA. The Main object has an owning One-Many relationship with another object. The other object is stored in a HashMap. What sort of synchronization would fix this problem? It seems to happen at completely random times and is very unpredictable. Here is the exception I get:
Exception in thread "pool-1-t...
Is it possible to use PostgreSQL-like DISTINCT ON in EJB-QL query?
What i need to do is to fetch from db records that are distinct on 3 of 10 columns.
...
We are connecting to a SQL Server to persist our EJB3 objects. These objects are annotated up with @Column.
If the column name in the database starts with a capital letter (E.g. OrderName) will the ejb annotation have case sensitivity issues if the element is defined like such:
@Column
String orderName
Thanks
...