hibernate.cfg.xml 文件
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>    <session-factory>
        <property name="hbm2ddl.auto">update</property>
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/kinodata</property>
        <property name="connection.username">root</property>
        <property name="connection.password">root123</property>
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="myeclipse.connection.profile">kinodata</property>
     <property name="hbm2ddl.auto">update</property>
    
     <mapping resource="cn/hbm/domain/Admin.hbm.xml"/>
    </session-factory></hibernate-configuration>
Admin.hbm.xml 文件
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0// EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mapping package="cn.hbm.domain">
<class name="Admin" table="admin">
<id name="id" column="admin_id" type="int">
<generator class="native"/>
</id>

<property name="name" column="admin_name"/>
<property name="birthday" column="admin_birthday"/>
</class>
</hibernate-mapping>
Admin.java
package cn.hbm.domain;import java.util.Date;public class Admin {
private int id;
private String name;
private Date birthday;

public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}}
BastTest.java
package cn.hbm.domain;import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class BastTest { public static void main(String[] args) {
System.out.println("test.base.start");
Configuration cfg = new Configuration();
cfg.configure();
SessionFactory sf = cfg.buildSessionFactory();

Session session = sf.openSession();
String hql = "from Admin as admin where admin.name=:name";

Query query = session.createQuery(hql);
query.setEntity("name", "admin");
if(query.list().isEmpty()){
System.out.println("true");
}else{
System.out.println("false");
}


session.close();
System.out.println("test");
System.out.println("end");
}}出现的错误
Exception in thread "main" org.hibernate.MappingException: Unknown entity: java.lang.String
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:628)
at org.hibernate.impl.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:715)
at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:520)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:545)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:110)
at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:67)
at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:514)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1593)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at cn.hbm.domain.BastTest.main(BastTest.java:22)