Unable to locate appropriate constructor on class

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;
	}

猜你喜欢

转载自alleni123.iteye.com/blog/2019528