Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Can't persist data into Oracle 10g by the default persistence layer of EJB 3.0 (Hibernate)

Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello pro,
I am trying to insert data into Oracle 10g but it is not successful. I had NO WARNING, NO ERRORS, but I STILL CAN'T persist an object :pissed: .

- file
public class User implements Serializable {
private String username;
private String password;
private Long id;

public User() {

public User(String username, String password) {
this.username = username;
this.password = password;

public String getUsername() {
return username;
public String getPassword() {
return password;

public void setUsername(String username) {
this.username = username;
public void setPassword(String password) {
this.password = password;

public Long getId() {
return id;

public void setId(Long id) { = id;

- persistence.xml file:
<persistence-unit name="scbcdejb">
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.connection.username" value="dzungdev" />
<property name="hibernate.connection.password" value="dzungdev" />
<property name="hibernate.connection.url" value="jdbc:oracle:thin:dzungdev/dzungdev@" />
<property name="hibernate.show_sql" value="true"/>
<!--<property name="hibernate.max_fetch_depth" value="3" />


- orm.xml file:
<entity class="dzung.entity.User" access="PROPERTY">
<table name="M3_USER"></table>
<sequence-generator name="user_seq" sequence-name="M3_USER_SEQ"/>
<id name="id">
<column name="id" />
<generated-value strategy="SEQUENCE" generator="user_seq"/>
<basic name="password">
<column name="password" />
<basic name="username">
<column name="username" />

- This is file:

public class Client {
public static void main(String[] args) {
emf = Persistence.createEntityManagerFactory("scbcdejb");
EntityManager em = emf.createEntityManager();
try {
User u1 = new User("dzungdev", "test");
System.out.println("Go here");
} finally {

My console is display with: Hibernate: select M3_USER_SEQ.nextval from dual
Go here

NO ERROR, NO WARNING but when I go to the schema to see data, nothing in the M3_USER table.

Are there someone to give me an advice :(
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You have to use sync your persistent entities to databse.

}catch(Exception exception){

tan dung dang
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank Uppala, now it runs well.
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic