mysql 外键为空_mysql 外键为空 查询出错

从后台查询项目出现问题,添加项目正常,但是在执行findProjectByAll()函数时出现问题,Hibernate:

select accounterd0_.id as id1_, accounterd0_.t_name as t2_1_,

accounterd0_.t_password as t3_1_, accounterd0_.t_role as t4_1_,

accounterd0_.t_remark as t5_1_ from t_accounter accounterd0_ where

accounterd0_.t_name=? and accounterd0_.t_password=? and

accounterd0_.t_role=?

Hibernate: select accounterd0_.id as id1_, accounterd0_.t_name as

t2_1_, accounterd0_.t_password as t3_1_, accounterd0_.t_role as

t4_1_, accounterd0_.t_remark as t5_1_ from t_accounter accounterd0_

where accounterd0_.t_name=? and accounterd0_.t_password=? and

accounterd0_.t_role=?

Hibernate: select accounterd0_.id as id1_, accounterd0_.t_name as

t2_1_, accounterd0_.t_password as t3_1_, accounterd0_.t_role as

t4_1_, accounterd0_.t_remark as t5_1_ from t_accounter accounterd0_

where accounterd0_.t_name=? and accounterd0_.t_password=? and

accounterd0_.t_role=?

Hibernate: select projectdao0_.id as id2_, projectdao0_.t_name as

t2_2_, projectdao0_.t_code as t3_2_, projectdao0_.t_sort as t4_2_,

projectdao0_.t_sort_code as t5_2_, projectdao0_.t_start_date as

t6_2_, projectdao0_.t_end_date as t7_2_, projectdao0_.t_fund_amount

as t8_2_, projectdao0_.t_fund_source as t9_2_,

projectdao0_.t_last_income as t10_2_, projectdao0_.t_total_income

as t11_2_, projectdao0_.t_income_note as t12_2_,

projectdao0_.t_budget_status as t13_2_, projectdao0_.t_if_end as

t14_2_, projectdao0_.t_fact_end_date as t15_2_,

projectdao0_.t_loan_status as t16_2_, projectdao0_.t_loaning as

t17_2_, projectdao0_.t_remark as t18_2_, projectdao0_.user_id as

user19_2_, projectdao0_.accounter_id as accounter20_2_ from

t_project projectdao0_

10:22:33,277 ERROR ProjectDao:116 -

啥问题呢,还以为是添加项目是没有添加外键取不到关联表的信息,但是修改程序后还是这样子

调了好久怀疑可能是外键accounter_id的为null的问题,手动将这个属性值改为1,发现问题就解决了;

可是Project这条记录和Accounter的关联关系还没有确定怎么能够确定外键值呢,怎么办?

问题解决了,原来

hbm.xml文件中外键有一个属性是not-null,默认为true,若是需要外键为空必须将其改为false,问题就解决了……,晕,纠结了我两天……

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值