「」「」「」hibernat双向多对多怎么不能生成表呢?卡了我3天了,求救,谢谢

etracer 2014-04-06 12:22:45
错误如下
2014 年 4 月
Hibernate: select employee0_.employee_key as employee1_0_, employee0_.no as no0_, employee0_.password as password0_, employee0_.level as level0_, employee0_.name as name0_, employee0_.sex as sex0_, employee0_.birthday as birthday0_, employee0_.address as address0_, employee0_.portable_tel as portable9_0_, employee0_.house_tel as house_tel0_, employee0_.corporation_tel as corpora11_0_, employee0_.email as email0_, employee0_.enter_company_date as enter_c13_0_, employee0_.out_company_date as out_com14_0_, employee0_.work_address as work_ad15_0_, employee0_.department as department0_, employee0_.position as position0_, employee0_.departmentTel as departm18_0_ from employee employee0_ where employee0_.employee_key=?
Hibernate: select monthpayli0_.employee_key as employee1___, monthpayli0_.month_key as month_key__, monthpay1_.month_pay_key as month_pa1_0_, monthpay1_.regular_salary as regular_2_0_, monthpay1_.pay_date as pay_date0_, monthpay1_.area_allowance as area_all4_0_, monthpay1_.manager_allowance as manager_5_0_, monthpay1_.house_allowance as house_al6_0_, monthpay1_.commuting_allowance as commutin7_0_, monthpay1_.weekday_overtime_allowance as weekday_8_0_, monthpay1_.playday_overtime_allowance as playday_9_0_, monthpay1_.business_trip as busines10_0_, monthpay1_.work_day as work_day0_, monthpay1_.health_insurance as health_12_0_, monthpay1_.welfare_insurance as welfare13_0_, monthpay1_.employment_insurance as employm14_0_, monthpay1_.income_tax as income_tax0_, monthpay1_.advance as advance0_, monthpay1_.temporary_payment as tempora17_0_, monthpay1_.loan_insurance as loan_in18_0_, monthpay1_.life_insurance as life_in19_0_, monthpay1_.adjustment as adjustment0_, monthpay1_.deduction as deduction0_, monthpay1_.provide as provide0_ from employee_monthPay monthpayli0_ inner join month_pay monthpay1_ on monthpayli0_.month_key=monthpay1_.month_pay_key where monthpayli0_.employee_key=?
[WARN] JDBCExceptionReporter - SQL Error: 1146, SQLState: 42S02
[ERROR] JDBCExceptionReporter - Table 'mnettest.employee_monthpay' doesn't exist
[WARN] JDBCExceptionReporter - SQL Error: 1146, SQLState: 42S02
[ERROR] JDBCExceptionReporter - Table 'mnettest.employee_monthpay' doesn't exist
error:net.sf.hibernate.exception.SQLGrammarException: could not initialize collection: [com.m_netd.businessobjects.Employee.monthPayList#888888]
[INFO] DriverManagerConnectionProvider - cleaning up connection pool: jdbc:mysql:///mnettest
-------------------------------------------


public class MonthPay extends BaseObject {

//本給
private int regularSalary;
//本給時間
private Date payDate;
//勤務地手当
private int areaAllowance;
//管理職手当
private int managerAllowance;
//住宅手当
private int houseAllowance;
//通勤手当
private int commutingAllowance;
//平日外手当
private int weekdayOvertimeAllowance;
//祝日外手当
private int playdayOvertimeAllowance;
//出張交通費
private int businessTrip;
//有給日数
private int workDay;
//健康保険
private int healthInsurance;
//年金保険
private int welfareInsurance;
//雇用保険
private int employmentInsurance;
//所得税
private int incomeTax;

private int advance;

//仮払旅費
private int assumeTravel;
//前払金
private int temporaryPayment;
//貸金保険料
private int loanInsurance;
//生命保険料
private int lifeInsurance;
//調整料
private int adjustment;
//控除額計
private int deduction;
//支給額計
private int provide;

//private Employee employee;
private Set <Employee> employee=new HashSet(); <------此处
。。。。。
}




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package = "com.m_netd.businessobjects">
<class name="MonthPay" table="month_pay">
<id name="id" type="string" column="month_pay_key">
<generator class="uuid.hex"/>
</id>

<property name="regularSalary" column="regular_salary"/>
<property name="payDate" column="pay_date"/>
<property name="areaAllowance" column="area_allowance"/>
<property name="managerAllowance" column="manager_allowance"/>
<property name="houseAllowance" column="house_allowance"/>
<property name="commutingAllowance" column="commuting_allowance"/>
<property name="weekdayOvertimeAllowance" column="weekday_overtime_allowance"/>
<property name="playdayOvertimeAllowance" column="playday_overtime_allowance"/>
<property name="businessTrip" column="business_trip"/>
<property name="workDay" column="work_day"/>
<property name="healthInsurance" column="health_insurance"/>
<property name="welfareInsurance" column="welfare_insurance"/>
<property name="employmentInsurance" column="employment_insurance"/>
<property name="incomeTax" column="income_tax"/>
<property name="advance" column="advance"/>
<property name="temporaryPayment" column="temporary_payment"/>
<property name="loanInsurance" column="loan_insurance"/>
<property name="lifeInsurance" column="life_insurance"/>
<property name="adjustment" column="adjustment"/>
<property name="deduction" column="deduction"/>
<property name="provide" column="provide"/>
<!--
<many-to-one name="employee" column="employee_key" class="Employee"></many-to-one>
-->
<set name="employee" inverse="false" cascade="all" table="employee_monthPay">
<key column="month_key"></key>
<many-to-many class="Employee" column="employee_key"></many-to-many> <------此处
</set>

</class>
</hibernate-mapping>



public class Employee extends BaseObject {

//社員NO.:
private String no;
//パースワード
private String password;
//ユーザー権限
private String level;
private EmployeeInfo employeeInfo;
//private List<MonthPay> monthPayList;
//private List<Funds> fundsList;
private Set <MonthWorkTime> monthWorksList=new HashSet();
]private Set <MonthPay> monthPayList=new HashSet();; <------此处
。。。。。。
}




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package = "com.m_netd.businessobjects">
<class name="Employee" table="employee">
<id name="id" type="string" column="employee_key">
<generator class="uuid.hex"/>
</id>
<property name="no" column="no"/>
<property name="password" column="password"/>
<property name="level" column="level"/>

<component name="employeeInfo" class="EmployeeInfo">
<property name="name" column="name"/>
<property name="sex" column="sex"/>
<property name="birthday" column="birthday"/>
<property name="address" column="address"/>
<property name="portableTel" column="portable_tel"/>
<property name="houseTel" column="house_tel"/>
<property name="corporationTel" column="corporation_tel"/>
<property name="email" column="email"/>
<property name="enterCompanyDate" column="enter_company_date"/>
<property name="outCompanyDate" column="out_company_date"/>
<property name="workAddress" column="work_address"/>
<property name="department" column="department"/>
<property name="position" column="position"/>
<property name="departmentTel" column="departmentTel"/>

</component>
<!--
<list name="monthPayList">
<key column="employee_key"></key>
<index column="month_pay_number"></index>
<one-to-many class="MonthPay"/>
</list>

<list name="fundsList" lazy="true">
<key column="employee_key"></key>
<index column="fusdss_number"></index>
<one-to-many class="Funds"/>
</list>
-->
<set name="monthWorksList" inverse="true" cascade="all">
<key column="employee_key"></key>
<one-to-many class="MonthWorkTime"/>
</set>

<set name="monthPayList" inverse="false" cascade="all" table="employee_monthPay">
<key column="employee_key"></key>
<many-to-many class="MonthPay" column="month_key"></many-to-many>
</set> <------此处

<!--
<list name="monthWorksList" lazy="false">
<key column="employee_key"></key>
<index column="employee_index" type="integer"></index>
<one-to-many class="MonthWorkTime"/>
</list>
-->
</class>
</hibernate-mapping>

...全文
186 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
etracer 2014-04-07
  • 打赏
  • 举报
回复
我配置文件没写好
etracer 2014-04-07
  • 打赏
  • 举报
回复
[INFO] DatabaseMetadata - table not found: employee_monthPay [ERROR] SchemaUpdate - Unsuccessful: create table employee_monthPay (employee_key varchar(255) not null, month_key varchar(255) not null, primary key (employee_key, month_key)) [ERROR] SchemaUpdate - Specified key was too long; max key length is 1000 bytes
小灯光环 2014-04-06
  • 打赏
  • 举报
回复
sql格式错误。。这么长的SQL你放到数据库的查询编辑器跑一下。。数据库不报错了再放到程序里。

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧