当前位置:首页 > 开发 > 系统架构 > 架构 > 正文

Unable to locate appropriate constructor on class

发表于: 2014-02-20   作者:alleni123   来源:转载   浏览:
摘要: org.hibernate.hql.internal.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [com.lj.core.model.Channel] [select new Channel(c.id, c.name) from com.lj.core.model.Channel c wh
org.hibernate.hql.internal.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [com.lj.core.model.Channel] [select new Channel(c.id, c.name) from com.lj.core.model.Channel c where c.status=1 and c.isIndex=1 and c.type= 1]

在执行下述hql语句的时候出错,
"select new Channel(c.id, c.name) from Channel c where c.status=1 and c.isIndex=1"

原因是在这个hql语句中,使用了new Channel(c.id,c.name).

这样hibernate就会在我们的实体类中找相应的构造函数。
所以要在Channel.java类中建立对应的构造函数:

public Channel(int id, String name)
	{
		super();
		this.id = id;
		this.name = name;
	}

Unable to locate appropriate constructor on class

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号