Hi there,
I've got a Stateful Session bean where I create a object (in this case a user object) and saving it in my db. Now I just want so update this entry which doesn't work - a NullPointerExceptionis thrown instead. What is my fault here?
Bean
@Stateful
@Scope(ScopeType.SESSION)
@Name("Userdata")
public class UserdataBean implement...
My User entity class contains password hash field, which is a byte array with a fixed length (32 since it's an SHA-256 hash).
@Entity
public class User {
@Column(nullable=false)
private byte[] passwordHash;
...
}
As you can see, I haven't annotated it with anything special, just a NOT NULL.
This works, but will it perform...
What I have is an entity bean e.g. Entity (EJB 3) that keeps same type children in an ArrayList<Entity>, his parent <Entity> and a relation to another entity <Users>. Users can own many Entities, and vice-versa (many to many).
What I would like to do is override Entity.clone() (or have a new method) to deep-copy Entity along with clone...
Has:
class Container {
@Id
@Column(name="id")
protected long id;
@OneToMany
@JoinColumn(name="container_id", nullable=false)
protected Collection<Content> contents = new ArrayList<Content>();
}
and
class Content {
@Id
@Column(name="id")
protected long id;
@Column(name="link_id")
protec...
I have just implemented exception handling for a unique-constraint of a JPA entity. It is working as I want it to, but when triggered dumps the handled exceptions to the container logfile.
A JPA entity is managed by a SLSB (Service Façade). The Service Façade is called from another SLSB, which provides remoting capabilities based on JA...
Hi,
I am designing an application for collecting weather data. I have 2 POJO objects "Location" and "Record". Location contains information about latitude and longitude and the current weather conditions, and Record contains all the weather information over time for a specific location thus having a Many-to-one relation with Location. T...
How would you configure annotations in the following example code? I'd like to stick with JPA annotations only and avoid Hibernate specific dependencies. Is the code below correct?
@Entity
public class RefExample extends RefData {
}
(There will be multiple versions of these classes, RefSomeOtherExample, etc, and one db table per clas...
I have a class:
public class Email {
private String name;
private String domain;
public String toString() {
return name + "@" + domain;
}
}
I want to use it in JPA column:
@Entity
public class User {
@Id private Integer id;
private Email email;
}
This is what Hibernate says:
org.hibernate.MappingException: Could ...
My custom type is (no default constructor!):
package com.XXX.common;
public class Email implements Serializable {
private String e;
public Email(String str) {
e = str;
}
}
My entity in Hibernate 3.5.6:
package com.XXX.persistence;
import com.XXX.common;
@Entity
@TypeDef(
name = "email",
defaultForType = Email.class,
t...
Hi,
I have three entities in my system - one of which must be updated when fields on the other two are changed:
@Entity
public class Order {
private String name;
private Integer quantity;
private String status;
}
@Entity
public class OrderLocation {
private String status;
private String desc;
}
@Entity
public cla...
Hello!
I am using the Java Enterprise Edition with JPA(Hibernate) for a Server-Client application (via EJB).
The program stores a lot of data in a database that needs to be transfered to the client.
Because I want to transfer as less data as possible I do not want to transfer objects twice.
I want to demonstrate my problem with a small...
Has:
@MappedSuperclass
class Superclass {
@Id
@Column(name = "id")
protected long id;
@Column(name="field")
private long field;
}
and
@Entity
class Subclass extends Superclass {
}
How to annotate inherited id with @GeneratedValue and field with @Index within Subclass?
...
I use Eclipselink as my JPA provider, how can I make a field auto increment?
...
I have been reporting with jasperreports and JPA, all this reports are just "catalogs" in which the only information is an entity or some times an entity with it's related entities.
Now i have to design reports with very complex information (grouping, summarization, fields not part of an entity and so on) which is not possible with my e...
I've read this article on JPA concurrency, but either I am too thick or it is not explicit enough.
I am looking to do a database-controlled atomic update-if-found-else-insert operation (an UPSERT).
It looks to my poor slow brain that I can--within a transaction of course--run a named query with a lock mode of PESSIMISTIC_WRITE, see if ...
Hi,
I have a problem using JPA with Oracle and grouping by hour.
Here's the scenario:
I have an entiry named EventData. This entity has a java.util.Date field named startOfPeriod. This field maps in a table field of datatype DATE.
The query I'm using is something like:
select min(ed.startOfPeriod) as eventDate,
(...)
from
Event e inner ...
I'm trying to use one Named EntityQuery that will allow nulls in the Where clause using '='
Is there a way of setting ANSI_NULLS off or "set ANSI_NULLS off" in JPA the same way as in SQL?
My JBOSS Data source file looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>jdb...
Hi,
I have a small Wicket app that I can deploy to Glassfish v3 without any problems. I also have a JAX-RS webservice that includes a jar file that contains JPA entity beans and stateless service beans that deploys successfully. However, when I try to deploy a different Wicket application that makes use of the same entity/service jar,...
Hi,
I'm trying to use Hibernate 3.5.5 with Spring HibernateJpaVendorAdapter on Glassfish V2 but I'm getting the following exception when the Spring context is initialised:
java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getSharedCacheMode()Ljavax/persistence/SharedCacheMode;
at org.hibernate.ejb.util.LogHelper....
Can some one suggets me how to build up following query using JPA Criteria builder api.
SELECT id,status,created_at from transactions where status='1'
and currency='USD' and appId='123' order by id
Its better if i can find a solution which creates dynamically based on the parameters given as a map using metamodel classes or any ot...