We are in the beginning coding phase for project that we are using JPA with. We used the tools in Netbeans to generate our JPA entities based on our schema. It worked pretty well, but as always we have had to customize the entities a good bit since then.
We made a decent size change to our schema (added a table, and swapped around relat...
i'm using jpa and eclipselink. it says version 2.0.2.v20100323-r6872 for eclipselink. it's an SE application, small. local persistence unit. i am using a postgres database. i have some code the wakes up once per second and does a jpa query on a table. it's polling to see whether some fields on a given record change. but when i update a f...
I have a native query that does a batch insert into a MySQL database:
String sql = "insert into t1 (a, b) select x, y from t2 where x = 'foo'";
EntityTransaction tx = entityManager.getTransaction();
try {
tx.begin();
int rowCount = entityManager.createNativeQuery(sql).executeUpdate();
tx.commit();
...
Is it possible to do indexed element access in JPQL like in HQL :
select o from Order o where o.items[0].id = 1234
I couldn't find something related in the JPA 2 specs,
I am targeting EclipseLink JPA here, so if you come up with an EclipseLink solution, that's ok as well, although a JPQL standard solution is preferred.
...
I'm just getting to grips with JPA in a simple Java web app running on Glassfish 3 (Persistence provider is EclipseLink). So far, I'm really liking it (bugs in netbeans/glassfish interaction aside) but there's a thing that I want to be able to do that I'm not sure how to do.
I've got an entity class (Article) that's mapped to a database...
I have some philosophical intuitive feeling that adding fields which doesn't mapped to the DB corrupts entity classes and is a wrong way of solving problems.
But are there any concrete situations where using @Transient fields leads to implicit and hard fixing problems?
For example, is it possible that adding or removing 2nd level cache...
Anyone know a tool for generating Java class with JPA annotations from an SQL script?
Batch process would be a plus since I have a large amount of sql objects.
...
I've been looking in the web for examples on the aggregates like count but it seems all of them are using the aggregate alone.
SELECT field, count(*) FROM table GROUP BY field
Should have something like:
field.value1, x1
field.value2, x2
....
I'm looking for a pure JPA answer for this one. If not I guess I can then do further queri...
Hi all,
I'm a newbie with JPA.
I need to map a search object to a table.
The search object has only and id, name. The big object has more fileds id, name, adress and more.
I use this as big object
view plaincopy to clipboardprint?
I use this as big object
@Entity
@Table(name="users")
public class User {
@Id
@GeneratedValue(strate...
Hello!
I'm trying to do something which is easy as pie in PHP & Co:
SELECT COUNT(x) as numItems, AVG(y) as average, ... FROM Z
In PHP I would get a simple array like [{ numItems: 0, average: 0 }] which I could use like this:
echo "Number of Items: " . $result[0]['numItems'];
Usually in JPQL you only query single objects or single co...
I've got a problem with the removal of entities in my JPA application: basically, I do in this EJB Business method:
load photo list ;
for each photo {
//UPDATE
remove TagPhoto element from @OneToMany relation
//DISPLAY
create query involving TagPhoto
...
}
and this last query always throws an EntityNotFoundExceptio...
I have two tables
tab1 { col1 (PK), col2, col3 }
tab2 { col1, col2(PK), col3 }
I am using Hibernate annotation for joining using "OneToOne"
I have the below Hibernate class for tab1
class tab1 {
@OneToOne
@JoinColumn(name = "col2", referencedColumnName = "col1")
private tab2 t2;
}
i was expecting to run the below sql
se...
Hi my idea is to retrieve all users from google app domain using java. I retrieved all the user using Provisioning api but when i tried to store the data in the table using JPA its returning time out Error.... I dont know how to store the entire details at a stretch. Please Help me...
Regards,
sharun.
...
I tried the following code:
Appsprovisioning.java
public void calluser() throws AppsForYourDomainExceptiion IOException
{
for(UserEntry userEntry : retrieveAllUsers().getEntries())
{
m[x]= userEntry.getTitle().getPlainText();
x++;
}
try
{
for(int i=0;i<x;i++)
{
String sd=...
@Embedded
public class EmbedMe {
private String prop1;
private String prop2;
}
@Entity
public class EncryptedEmbedded {
@Embeddable
private EmbedMe enc;
}
I am current using Jasypt for encryption. Is there a way to indicate that the @Embeddable in EncryptedEmbedded will use @Type(value = "newDeclaredTypeHere") per attr...
Hello,
I have a ManyToMany relationship between two classes, for instance class Customer and class Item. A customer can buy several items and an item can be bought by different customers. I need to store extra information in this relationship, for example the day when the item was bought. I wonder how is this usually modelled in JPA, ca...
I have created the following entity bean, and specified two columns as being unique. Now my problem is that the table is created without the unique constraint, and no errors in the log.
Does anyone have an idea?
@Entity
@Table(name = "cm_blockList", uniqueConstraints = @UniqueConstraint(columnNames = {"terminal", "blockType"}))
public c...
Hi
I use Google App Engine with datanucleus and JPA. I'm having a real hard time grasping how I'm supposed to read stuff from data store and pass it to JSP. If I load a list of POJOs with entitymanager and pass it to JSP, it crashes to org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed.
I understand why thi...
Maybe I got it wrong but i though that JPA was able to update an existing table (model changed adding a column) but is not working in my case.
I can see in the logs eclipselink attempting to create it but failing because it already exists. Instead of trying an update to add the column it keeps going.
<property name="javax.persistence.j...
Hi all,
I'm stuck with a database which is using multi-field primary keys. I have a situation where I have a master and details table, where the details table's primary key contains fields which are also the foreign key's the the master table. Like this:
Master primary key fields:
master_pk_1
Details primary key fields:
maste...