【发布时间】:2018-01-09 15:53:30
【问题描述】:
这是我的 pojo 课
包 com.sathya.entity;
公共类客户{私人字符串客户ID;私有字符串 顾客姓名;私有字符串位置;公共客户(){} 公共客户(字符串 customerId){ this.customerId=customerId;
} 公共客户(字符串客户ID,字符串客户名称,字符串 位置) { this.customerId=customerId; this.customerName=客户名称;这个位置=位置; } 上市 String getCustomerId() { return customerId; } 公共无效 setCustomerId(String customerId) { this.customerId = customerId; } public String getCustomerName() { return customerName; } 上市 无效 setCustomerName(String customerName) { this.customerName = 顾客姓名; } public String getLocation() { 返回位置; } 公共无效 setLocation(字符串位置){ this.location = 地点; } 公共字符串 toString() { 返回 "客户["+customerId+","+customerName+","+location+"]"; } }
我的客户程序是
> package com.sathya.test;
>
>
>
> import org.hibernate.Session;
> import org.hibernate.SessionFactory;
> import org.hibernate.Transaction;
> import org.hibernate.cfg.Configuration;
>
> import com.sathya.entity.Customer;
>
> public class InsertCustomer {
>
> public static void main(String[] args)
> {
> Configuration config=new Configuration();
> config.configure("com/sathya/config/hibernate.cfg.xml");
> SessionFactory factory=config.buildSessionFactory();
> Session session=factory.openSession();
> Customer cust=new Customer();
> cust.setCustomerName("sathya");
> cust.setLocation("Hyd");
> Transaction tx=session.beginTransaction();
> session.save(cust);
> tx.commit();
> session.close();
> factory.close();
> }
>
> }
*
在尝试执行程序时出现 ORA-01400: cannot insert NULL into ("SYSTEM"."CUSTOMER"."CUSTOMERID") 等错误
*
【问题讨论】: