0

Hibernateでサンプルプログラムを実行しようとすると...次のエラーが発生しました...それらを修正するアイデアはありますか?

Hibernate: insert into USER_DETAILS (data, date, phonenumber, USER_NAME, USER_ID) values (?, ?, ?, ?, ?)
Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
    at org.rathan.dto.Test.main(Test.java:31)
Caused by: java.sql.BatchUpdateException: ORA-01747: invalid user.table.column, table.column, or column specification

    at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:367)
    at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9119)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
    ... 8 more

これが私のメインクラスです:

package org.rathan.dto;

import java.util.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class Test {

    public static void main(String[] args) {
    System.out.println(1);
    UserDetails user=new UserDetails();
    System.out.println(2);
    user.setUserid(100);
    user.setUsername("Rathan");
    //user.setSalary(10000);
    user.setPhonenumber("9989242487");
    user.setAddress("My Home address");
    user.setData("blah....blah....blah....blah....blah....");
    user.setDate(new Date());
    System.out.println(3);
    SessionFactory factory=new Configuration().configure().buildSessionFactory();
    System.out.println(4);
    Session session=factory.openSession();
    System.out.println(5);
    session.beginTransaction();
    System.out.println(6);
    session.save(user);
    System.out.println(7);
    session.getTransaction().commit();
    System.out.println(8);
    session.close();
}}

ここでは、System.out.println(7)まで実行できます。その後、エラーが発生しました。

4

1 に答える 1

0

これがUserDetails.javaです

    package org.rathan.dto;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
@Table (name="USER_DETAILS")
public class UserDetails {
    @Id
    @Column (name="USER_ID")
    private int userid;
    @Column (name="USER_NAME")
    private String username;
    @Transient
    private String Address;
    private static long salary;
    private String phonenumber;
    @Lob
    private String data;
    @Temporal (TemporalType.DATE)
    private Date mydate;

public String getData() {
        return data;
    }
    public void setData(String data) {
        this.data = data;
    }

public Date getMydate() {
        return mydate;
    }
    public void setMydate(Date mydate) {
        this.mydate = mydate;
    }
public String getAddress() {
        return Address;
    }
    public void setAddress(String address) {
        Address = address;
    }
    public static long getSalary() {
        return salary;
    }
    public static void setSalary(long salary) {
        UserDetails.salary = salary;
    }
    public String getPhonenumber() {
        return phonenumber;
    }
    public void setPhonenumber(String phonenumber) {
        this.phonenumber = phonenumber;
    }
public int getUserid() {
    return userid;
}
public void setUserid(int userid) {
    this.userid = userid;
}
public String getUsername() {
    return username;
}
public void setUsername(String username) {
    this.username = username;
}
}
于 2012-04-12T15:34:41.887 に答える