Having a little trouble with openJPA persiting with MySQL, whilst new rows
are being created for each em.persist(dao) the rows are bring populated with
'NULL' values for each column!
I get no error in my logs and debugging shows that the property values are
there right upto the em.persist(dao) line of code.
DAO
@Entity
@Table(name = "tbl_user_details")
public class UserRegistrationDao implements java.io.Serializable {
private int id;
private String firstname;
private String surname;
private String email;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
@Basic
@Column(name="firstname")
public synchronized final String getFirstname() {
return this.firstname;
}
public synchronized final void setFirstname(String firstname) {
this.firstname = firstname;
}
@Basic
@Column(name="surname")
public synchronized final String getSurname() {
return this.surname;
}
public synchronized final void setSurname(String surname) {
this.surname = surname;
}
@Basic
@Column(name="email")
public synchronized final String getEmail() {
return this.email;
}
public synchronized final void setEmail(String email) {
this.email = email;
}
}
Bean
@PersistenceContext(unitName = "users", type =
PersistenceContextType.EXTENDED)
private EntityManager _em;
@Override
public boolean create(Map<String, Object> args) {
UserRegistrationDao dao = new UserRegistrationDao(args);
_em.persist(dao); // *** upto here values are present ***
persistence.xml
<persistence-unit name="users" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>jdbc/users</jta-data-source>
<!-- Enumerate your persistent classes here. -->
<class>com.project1.business.dao.UserRegistrationDao</class>
<properties>
<property name="openjpa.ConnectionURL"
value="jdbc:mysql://localhost:3306/users"/>
<property name="openjpa.ConnectionDriverName"
value="com.mysql.jdbc.Driver"/>
<property name="openjpa.ConnectionUserName"
value="root"/>
<property name="openjpa.ConnectionPassword"
value="rootpass123"/>
</properties>
</persistence-unit>
--
View this message in context:
http://n2.nabble.com/openJPA-with-EJB3-MySQL-on-WAS7-tp4113103p4113103.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.