`

hibernate删除问题:not-null property references a null or transient value

阅读更多
org.springframework.dao.DataIntegrityViolationException: 
not-null property references a null or transient value: 
com.crms.bean.Client.employee; nested exception is org.hibernate.PropertyValueException: 

not-null property references a null or transient value: com.crms.bean.Client.employee        root cause


hibernate中删除时,传入的对象必须是要有值的。如删除client,在如下代码中:通过

jsp中传来的参数client.clientIdclient接受,this.clientService.findById(client.getClientId())得到对象client


public String execute() throws Exception

    {

       client  = this.clientService.findById(client.getClientId());

      

        this.clientService.deleteClient(client);

      

       return SUCCESS;

    }

 

Dao中的方法:(只能用这个)

public Client findById(Integer id) {

       //String hql="from Client c where c.client_id="+id;

    return (Client) this.getHibernateTemplate().get(Client.class, id);

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics