Hibernate 插入到 oracle DB 中,意外标记:VALUES
我正在尝试在 Oracle 10g DB 中创建插入查询。它一直给我这个错误:
ERROR PARSER:33 - line 1:115:unexpected token:VALUES
这是我要插入的DAO方法
public void uploadFile(String createUser, Integer id, byte[] file, String name, String size, String mime) {
Session session = getSessionFactory().openSession();
try {
Query up = session.createSQLQuery("INSERT INTO FILES(CREATE_DATE, CREATE_USER, FILE_DATA, FILE_ID, FILE_MIME, FILE_NAME, FILE_SIZE, ID) VALUES(SYSDATE, :createUser, :file, FILE_ID_SEQ.nextval, :mime, :name, :size, :id) ");
up.setInteger("id", id);
up.setBinary("file", file);
up.setString("name", name);
up.setString("size", size);
up.setString("mime", mime);
up.setString("createUser", createUser);
up.executeUpdate();
} catch(HibernateException e) {
throw new HibernateException(e);
} finally {
session.close();
}
}
I am trying to do create a insert query into my Oracle 10g DB. It keeps giving me this error:
ERROR PARSER:33 - line 1:115: unexpected token: VALUES
this is my DAO method to insert
public void uploadFile(String createUser, Integer id, byte[] file, String name, String size, String mime) {
Session session = getSessionFactory().openSession();
try {
Query up = session.createSQLQuery("INSERT INTO FILES(CREATE_DATE, CREATE_USER, FILE_DATA, FILE_ID, FILE_MIME, FILE_NAME, FILE_SIZE, ID) VALUES(SYSDATE, :createUser, :file, FILE_ID_SEQ.nextval, :mime, :name, :size, :id) ");
up.setInteger("id", id);
up.setBinary("file", file);
up.setString("name", name);
up.setString("size", size);
up.setString("mime", mime);
up.setString("createUser", createUser);
up.executeUpdate();
} catch(HibernateException e) {
throw new HibernateException(e);
} finally {
session.close();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅支持 INSERT INTO ... SELECT ... 形式;不是 INSERT INTO ... VALUES ... 形式。
核心参考,第 13 章。
抱歉,这是普通的 sql,我什么也没说。
Only the INSERT INTO ... SELECT ... form is supported; not the INSERT INTO ... VALUES ... form.
Core reference, chapter 13.
Ups, sorry, It is plain sql, I say nothing.
检查列列表,您错过了尺寸:
Check the column lists, you missed the size: