我正在使用这种方法从DAO中的数据库中检索一些数据:
@Override
@Transactional
public List<History> findLastHistoriesByCount(int gHistoriesCount) {
List<History> result = new ArrayList<History>();
result = entityManager
.createQuery(
"SELECT h FROM History h ORDER BY h.eventDate DESC",
History.class).setMaxResults(gHistoriesCount).getResultList();
return result;
}
这是我的历史课:
public class History implements Serializable {
...
@ManyToOne
@JoinColumn(name = "ID_CONTRACT_HISTORY", nullable = true)
private ContractHistory contractHistory;
@ManyToOne
@JoinColumn(name = "ID_SALARY_HISTORY", nullable = true)
private SalaryHistory salaryHistory;
...
}
但我正面临这个例外:
javax.persistence.EntityNotFoundException:找不到标识为108的com.xxx.model.ContractHistory
虽然我确定我在ContractHistory表中的数据库中有那行
修改
我已经看到了带有@NotFound
注释的解决方案,我不希望它导致它只是我的旁路,因为我的数据就在那里!我想要撤回它。
编辑2 ** ContractHistory:**
public class ContractHistory extends implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
...
}
编辑3:
ContractHistory: (请不要介意我之前为此问题更改过的表名:
历史记录:
编辑4
异常之前的SQL查询:
Hibernate:
22:22:29,211 INFO [stdout] (http-localhost-127.0.0.1-8888-1) select
22:22:29,211 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon0_.id as id234_13_,
22:22:29,212 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon0_.ID_COMPANY_CONTRACT as ID3_234_13_,
22:22:29,212 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon0_.ID_COMPANY_CONTRACT_AVENANT as ID4_234_13_,
22:22:29,212 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon0_.ID_EVENT_TYPE as ID5_234_13_,
22:22:29,213 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon0_.timestamp as timestamp234_13_,
22:22:29,213 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon0_.ID_USER as ID6_234_13_,
22:22:29,213 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.id as id218_0_,
22:22:29,214 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.IDCLIENT as IDCLIENT218_0_,
22:22:29,214 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.endDate as endDate218_0_,
22:22:29,215 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.invoicePaymentDay as invoiceP3_218_0_,
22:22:29,215 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.percentage_Extra_Hours as percentage4_218_0_,
22:22:29,216 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.IDPROFILE as IDPROFILE218_0_,
22:22:29,216 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.rate as rate218_0_,
22:22:29,216 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.reference as reference218_0_,
22:22:29,217 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.secondRate as secondRate218_0_,
22:22:29,217 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.startDate as startDate218_0_,
22:22:29,218 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.thirdRate as thirdRate218_0_,
22:22:29,218 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.UPDATE_TIMESTAMP as UPDATE10_218_0_,
22:22:29,218 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon1_.IDUSER as IDUSER218_0_,
22:22:29,219 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client2_.id as id215_1_,
22:22:29,219 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client2_.address as address215_1_,
22:22:29,219 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client2_.BILLING_ADDRESS as BILLING3_215_1_,
22:22:29,220 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client2_.CLIENT_NAME as CLIENT4_215_1_,
22:22:29,220 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client2_.COMMENTS as COMMENTS215_1_,
22:22:29,220 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client2_.IDCOMPANY as IDCOMPANY215_1_,
22:22:29,221 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client2_.logo as logo215_1_,
22:22:29,221 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client2_.siren as siren215_1_,
22:22:29,222 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client2_.TVA_INTRACOMMUNAUTAIRE as TVA8_215_1_,
22:22:29,222 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client2_.UPDATE_TIMESTAMP as UPDATE9_215_1_,
22:22:29,222 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client2_.IDZIPCODE as IDZIPCODE215_1_,
22:22:29,223 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.id as id178_2_,
22:22:29,223 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.CV_FILENAME_PATH as CV2_178_2_,
22:22:29,223 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.birthdate as birthdate178_2_,
22:22:29,224 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.IDCIVILITY as IDCIVILITY178_2_,
22:22:29,225 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.IDCOMPANY as IDCOMPANY178_2_,
22:22:29,225 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.IDCOUNTRY as IDCOUNTRY178_2_,
22:22:29,226 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.deleted as deleted178_2_,
22:22:29,226 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.disponibility as disponib5_178_2_,
22:22:29,226 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.ENTRANCE_DATE as ENTRANCE6_178_2_,
22:22:29,227 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.EXIT_DATE as EXIT7_178_2_,
22:22:29,227 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.EXTERNE as EXTERNE178_2_,
22:22:29,227 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.firstname as firstname178_2_,
22:22:29,228 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.IMMEDIATE_DISPONIBILITY as IMMEDIATE10_178_2_,
22:22:29,228 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.lastname as lastname178_2_,
22:22:29,228 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.mail as mail178_2_,
22:22:29,228 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.OWNER as OWNER178_2_,
22:22:29,229 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.photo as photo178_2_,
22:22:29,229 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.SOCIALESECURITYCODE as SOCIALE14_178_2_,
22:22:29,230 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.UPDATE_TIMESTAMP as UPDATE15_178_2_,
22:22:29,230 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile3_.IDZIPCODE as IDZIPCODE178_2_,
22:22:29,230 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.id as id165_3_,
22:22:29,231 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.IDCIVILITY as IDCIVILITY165_3_,
22:22:29,231 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.ID_COMPANY as ID10_165_3_,
22:22:29,231 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.Fax_Number as Fax2_165_3_,
22:22:29,232 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.First_Name as First3_165_3_,
22:22:29,232 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.Last_Name as Last4_165_3_,
22:22:29,232 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.Mail_Address as Mail5_165_3_,
22:22:29,233 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.password as password165_3_,
22:22:29,233 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.phone_Number as phone7_165_3_,
22:22:29,233 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.photo as photo165_3_,
22:22:29,234 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.IDPROFILE as IDPROFILE165_3_,
22:22:29,234 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user4_.IDUSERROLE as IDUSERROLE165_3_,
22:22:29,235 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.id as id219_4_,
22:22:29,235 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.ID_COMPANY_CONTRACT as ID11_219_4_,
22:22:29,235 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.dateAvenant as dateAven2_219_4_,
22:22:29,236 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.endDate as endDate219_4_,
22:22:29,236 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.invoicePaymentDay as invoiceP4_219_4_,
22:22:29,236 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.rate as rate219_4_,
22:22:29,237 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.reference as reference219_4_,
22:22:29,237 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.secondRate as secondRate219_4_,
22:22:29,238 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.startDate as startDate219_4_,
22:22:29,238 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.thirdRate as thirdRate219_4_,
22:22:29,238 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.UPDATE_TIMESTAMP as UPDATE10_219_4_,
22:22:29,239 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon5_.IDUSER as IDUSER219_4_,
22:22:29,239 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.id as id218_5_,
22:22:29,239 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.IDCLIENT as IDCLIENT218_5_,
22:22:29,240 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.endDate as endDate218_5_,
22:22:29,240 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.invoicePaymentDay as invoiceP3_218_5_,
22:22:29,240 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.percentage_Extra_Hours as percentage4_218_5_,
22:22:29,241 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.IDPROFILE as IDPROFILE218_5_,
22:22:29,241 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.rate as rate218_5_,
22:22:29,241 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.reference as reference218_5_,
22:22:29,242 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.secondRate as secondRate218_5_,
22:22:29,242 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.startDate as startDate218_5_,
22:22:29,242 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.thirdRate as thirdRate218_5_,
22:22:29,242 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.UPDATE_TIMESTAMP as UPDATE10_218_5_,
22:22:29,243 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon6_.IDUSER as IDUSER218_5_,
22:22:29,243 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.id as id165_6_,
22:22:29,243 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.IDCIVILITY as IDCIVILITY165_6_,
22:22:29,243 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.ID_COMPANY as ID10_165_6_,
22:22:29,243 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.Fax_Number as Fax2_165_6_,
22:22:29,244 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.First_Name as First3_165_6_,
22:22:29,244 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.Last_Name as Last4_165_6_,
22:22:29,244 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.Mail_Address as Mail5_165_6_,
22:22:29,246 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.password as password165_6_,
22:22:29,246 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.phone_Number as phone7_165_6_,
22:22:29,246 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.photo as photo165_6_,
22:22:29,247 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.IDPROFILE as IDPROFILE165_6_,
22:22:29,247 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user7_.IDUSERROLE as IDUSERROLE165_6_,
22:22:29,247 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon8_.id as id233_7_,
22:22:29,247 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon8_.CODE_EVENT_TYPE as CODE2_233_7_,
22:22:29,247 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon8_.libelle as libelle233_7_,
22:22:29,248 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.id as id165_8_,
22:22:29,248 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.IDCIVILITY as IDCIVILITY165_8_,
22:22:29,248 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.ID_COMPANY as ID10_165_8_,
22:22:29,248 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.Fax_Number as Fax2_165_8_,
22:22:29,249 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.First_Name as First3_165_8_,
22:22:29,249 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.Last_Name as Last4_165_8_,
22:22:29,249 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.Mail_Address as Mail5_165_8_,
22:22:29,250 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.password as password165_8_,
22:22:29,250 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.phone_Number as phone7_165_8_,
22:22:29,250 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.photo as photo165_8_,
22:22:29,251 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.IDPROFILE as IDPROFILE165_8_,
22:22:29,251 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user9_.IDUSERROLE as IDUSERROLE165_8_,
22:22:29,252 INFO [stdout] (http-localhost-127.0.0.1-8888-1) civility10_.id as id167_9_,
22:22:29,252 INFO [stdout] (http-localhost-127.0.0.1-8888-1) civility10_.civility as civility167_9_,
22:22:29,253 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.id as id169_10_,
22:22:29,253 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.ID_TYPE as ID12_169_10_,
22:22:29,253 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.companyname as companyn2_169_10_,
22:22:29,253 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.CONTACT_MAIL as CONTACT3_169_10_,
22:22:29,254 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.CONTACT_NAME as CONTACT4_169_10_,
22:22:29,254 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.CONTACT_PHONE as CONTACT5_169_10_,
22:22:29,254 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.description as descript6_169_10_,
22:22:29,254 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.logo as logo169_10_,
22:22:29,255 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.siren as siren169_10_,
22:22:29,255 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.staffing as staffing169_10_,
22:22:29,255 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.street as street169_10_,
22:22:29,256 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.website as website169_10_,
22:22:29,256 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company11_.IDZIPCODE as IDZIPCODE169_10_,
22:22:29,257 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.id as id178_11_,
22:22:29,257 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.CV_FILENAME_PATH as CV2_178_11_,
22:22:29,257 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.birthdate as birthdate178_11_,
22:22:29,257 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.IDCIVILITY as IDCIVILITY178_11_,
22:22:29,258 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.IDCOMPANY as IDCOMPANY178_11_,
22:22:29,258 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.IDCOUNTRY as IDCOUNTRY178_11_,
22:22:29,258 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.deleted as deleted178_11_,
22:22:29,259 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.disponibility as disponib5_178_11_,
22:22:29,259 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.ENTRANCE_DATE as ENTRANCE6_178_11_,
22:22:29,259 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.EXIT_DATE as EXIT7_178_11_,
22:22:29,259 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.EXTERNE as EXTERNE178_11_,
22:22:29,260 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.firstname as firstname178_11_,
22:22:29,260 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.IMMEDIATE_DISPONIBILITY as IMMEDIATE10_178_11_,
22:22:29,260 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.lastname as lastname178_11_,
22:22:29,260 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.mail as mail178_11_,
22:22:29,261 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.OWNER as OWNER178_11_,
22:22:29,261 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.photo as photo178_11_,
22:22:29,261 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.SOCIALESECURITYCODE as SOCIALE14_178_11_,
22:22:29,261 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.UPDATE_TIMESTAMP as UPDATE15_178_11_,
22:22:29,262 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile12_.IDZIPCODE as IDZIPCODE178_11_,
22:22:29,262 INFO [stdout] (http-localhost-127.0.0.1-8888-1) userrole13_.id as id217_12_,
22:22:29,262 INFO [stdout] (http-localhost-127.0.0.1-8888-1) userrole13_.LABEL as LABEL217_12_
22:22:29,262 INFO [stdout] (http-localhost-127.0.0.1-8888-1) from
22:22:29,262 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company_contract_history companycon0_
22:22:29,263 INFO [stdout] (http-localhost-127.0.0.1-8888-1) inner join
22:22:29,263 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company_contract companycon1_
22:22:29,263 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on companycon0_.ID_COMPANY_CONTRACT=companycon1_.id
22:22:29,263 INFO [stdout] (http-localhost-127.0.0.1-8888-1) left outer join
22:22:29,263 INFO [stdout] (http-localhost-127.0.0.1-8888-1) client client2_
22:22:29,264 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on companycon1_.IDCLIENT=client2_.id
22:22:29,264 INFO [stdout] (http-localhost-127.0.0.1-8888-1) left outer join
22:22:29,264 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile profile3_
22:22:29,264 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on companycon1_.IDPROFILE=profile3_.id
22:22:29,264 INFO [stdout] (http-localhost-127.0.0.1-8888-1) left outer join
22:22:29,265 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user user4_
22:22:29,265 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on companycon1_.IDUSER=user4_.id
22:22:29,265 INFO [stdout] (http-localhost-127.0.0.1-8888-1) inner join
22:22:29,265 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company_contract_avenant companycon5_
22:22:29,265 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on companycon0_.ID_COMPANY_CONTRACT_AVENANT=companycon5_.id
22:22:29,266 INFO [stdout] (http-localhost-127.0.0.1-8888-1) left outer join
22:22:29,266 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company_contract companycon6_
22:22:29,266 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on companycon5_.ID_COMPANY_CONTRACT=companycon6_.id
22:22:29,266 INFO [stdout] (http-localhost-127.0.0.1-8888-1) left outer join
22:22:29,266 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user user7_
22:22:29,267 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on companycon5_.IDUSER=user7_.id
22:22:29,267 INFO [stdout] (http-localhost-127.0.0.1-8888-1) inner join
22:22:29,267 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company_contract_event_type companycon8_
22:22:29,267 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on companycon0_.ID_EVENT_TYPE=companycon8_.id
22:22:29,267 INFO [stdout] (http-localhost-127.0.0.1-8888-1) inner join
22:22:29,268 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user user9_
22:22:29,268 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on companycon0_.ID_USER=user9_.id
22:22:29,268 INFO [stdout] (http-localhost-127.0.0.1-8888-1) left outer join
22:22:29,268 INFO [stdout] (http-localhost-127.0.0.1-8888-1) civility civility10_
22:22:29,268 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on user9_.IDCIVILITY=civility10_.id
22:22:29,269 INFO [stdout] (http-localhost-127.0.0.1-8888-1) left outer join
22:22:29,269 INFO [stdout] (http-localhost-127.0.0.1-8888-1) company company11_
22:22:29,269 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on user9_.ID_COMPANY=company11_.id
22:22:29,269 INFO [stdout] (http-localhost-127.0.0.1-8888-1) left outer join
22:22:29,269 INFO [stdout] (http-localhost-127.0.0.1-8888-1) profile profile12_
22:22:29,270 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on user9_.IDPROFILE=profile12_.id
22:22:29,270 INFO [stdout] (http-localhost-127.0.0.1-8888-1) left outer join
22:22:29,270 INFO [stdout] (http-localhost-127.0.0.1-8888-1) user_role userrole13_
22:22:29,270 INFO [stdout] (http-localhost-127.0.0.1-8888-1) on user9_.IDUSERROLE=userrole13_.id
22:22:29,270 INFO [stdout] (http-localhost-127.0.0.1-8888-1) where
22:22:29,271 INFO [stdout] (http-localhost-127.0.0.1-8888-1) companycon0_.id=?
22:22:29,273 GRAVE [org.zkoss] (http-localhost-127.0.0.1-8888-1) : javax.persistence.EntityNotFoundException: Unable to find com.epro.model.CompanyContractHistory with id 108
编辑5:
我将查询更改为:“SELECT gb FROM GlobalHistory gb LEFT JOIN FETCH gb.companyContractHistory cc其中gb.id = 544和cc.id = 108”
然后我确实得到了这条线! (注意我正在使用 JOIN FETCH ),任何人都要小心解释一下吗?
答案 0 :(得分:3)
尝试:
@ManyToOne(fetch = FetchType.LAZY)
@NotFound(action = NotFoundAction.IGNORE)
答案 1 :(得分:-2)
我找到了解决方案:
在我的ContractHistory中,我有:
public class ContractHistory extends implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
@ManyToOne(optional = false)
@JoinColumn(name="ID_COMPANY_CONTRACT", nullable = true)
private CompanyContract companyContract;
...
}
删除optinal = false
后,我确实没有遇到任何问题。
FIW:当您强制关联时(即optional = false),它会信任您并假定存在地址,因为关联是强制性的。所以它直接用代理填充地址字段,知道有一个引用该人的地址(SOF)