arduino录音模块:用hibernate的HQL怎么写一个插入语句

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/09 04:44:02
如题!
比如一个SQL
insert into AA (id,userName,password) VALUES ('0001','Wang','123');
我该怎么给他变成HQL呢
如何写呢?
谢谢
谢谢你
可是为什么我一写 “SessionFactory sf = new Configuration().configure().buildSessionFactory();”
在Configuration 就提示我“Cannot instantiate the type Configuration”
在configure 就提示我 “The method configure() is undefined for the type Configuration”
谢谢

不是有映射文件吗?
比如你的数据库表为student
那么的你就应该有hibernate.cfg.xml配置文件和他的映射文件hibernate.hbm.xml,最后还应该有一个student表的映射类student.java
这3个文件.
然后你建一个实现类studentInsert
实现是
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();

student st=new student();
st.setId("0001");
st.setUserName("Wang");
st.setpassWord("123");
session.save(st);
tx.commit();
session.close();
就是这样.

String hqlInsert = "insert into DelinquentAccount (id, name) select c.id, c.name from Customer c where ...";
int createdEntities = s.createQuery( hqlInsert )
.executeUpdate();

有 插入语句的 用这个好些