openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russell Collins <Russell.Coll...@mclaneat.com>
Subject RE: openJPA with EJB3 MySQL on WAS7
Date Fri, 04 Dec 2009 17:29:23 GMT
Just a quick question.  Is the table already created or are you trying to use OpenJPA to create
the table?

-----Original Message-----
From: kpsuk [mailto:keithsecker@yahoo.co.uk] 
Sent: Friday, December 04, 2009 9:32 AM
To: users@openjpa.apache.org
Subject: openJPA with EJB3 MySQL on WAS7


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.

Mime
View raw message