我不知道配置有什么问题。我总是得到相同的警告信息。
主要课程
public class main {
private static SessionFactory factory;
public static void main(String[] args) {
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
DOCUMENT user = new DOCUMENT();
System.out.println("DOC_ID= "+ user.getDoc_id());
Query qry=session.createQuery("from DOCUMENT where doc_firm_id= 317989 ");
List results = qry.list();
for (Iterator iterator =
results.iterator(); iterator.hasNext();){
DOCUMENT result= (DOCUMENT) iterator.next();
System.out.print("First Name: " + result.getDoc_id());
}
session.close();
CoDMS.hbm.xml - > DATABASE文档中的DOCUMENT TABELA类名称
<class name="DOCUMENT" table="DOCUMENT">
<id name="doc_id" type="int">
<column name="DOC_ID" precision="10" scale="0" />
<generator class="assigned" />
</id>
<property name="doc_firm_id" type="int">
<column name="DOC_FIRM_ID" length="10" not-null="false" />
</property>
<property name="doc_status" type="string">
<column name="DOC_STATUS" length="30" not-null="true" />
</property>
<property name="doc_type" type="string">
<column name="DOC_TYPE" length="30" not-null="true" />
</property>
<property name="doc_name" type="string">
<column name="DOC_NAME" length="128" not-null="true" />
</property>
<property name="doc_upload_date" type="date">
<column name="DOC_UPLOAD_DATE" length="6" not-null="true" />
</property>
<property name="doc_content" type="binary">
<column name="DOC_CONTENT" length="6" not-null="true" />
DOCUMENT.JAVA
public class DOCUMENT {
private int doc_id;
private int doc_firm_id;
private String doc_status;
private String doc_type;
private String doc_name;
private Date doc_upload_date;
private byte[] doc_content;
private String doc_desc;
private String doc_uploades_system;
private String doc_uploader_ref;
private String doc_uploader_name;
private int doc_removed;
private String doc_category;
private String doc_public_id;
public String getDoc_public_id() {
return doc_public_id;
}
public void setDoc_public_id(String doc_public_id) {
this.doc_public_id = doc_public_id;
}
public String getDoc_category() {
return doc_category;
}
public void setDoc_category(String doc_category) {
this.doc_category = doc_category;
}
仅使用查询选择和Tabel名称连接到数据库时没有问题。我筋疲力尽了。请给我一些指导意见
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc*********</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.username">******</property>
<property name="connection.password">**********</property>
<property name="hibernate.default_schema">DMS</property>
<mapping class="DOCUMENT"/>
<mapping resource="CoDMS.hbm.xml"/>
<!-- DB schema will be updated if needed -->
<!-- <property name="hbm2ddl.auto">update</property> -->
</session-factory>
</hibernate-configuration>
答案 0 :(得分:0)
lis 25, 2016 9:43:27 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.2.4.Final}
lis 25, 2016 9:43:27 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
lis 25, 2016 9:43:27 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
lis 25, 2016 9:43:28 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
lis 25, 2016 9:43:28 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
lis 25, 2016 9:43:28 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:@proxy02-pci.te4.local:7104/co_te4]
lis 25, 2016 9:43:28 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {user=bzielinski, password=****}
lis 25, 2016 9:43:28 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
lis 25, 2016 9:43:28 AM org.hibernate.engine.jdbc.connections.internal.PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
lis 25, 2016 9:43:28 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect
lis 25, 2016 9:43:29 AM org.hibernate.type.BasicTypeRegistry register
INFO: HHH000270: Type registration [byte[]] overrides previous : org.hibernate.type.BinaryType@63070bab
lis 25, 2016 9:43:29 AM org.hibernate.type.BasicTypeRegistry register
INFO: HHH000270: Type registration [[B] overrides previous : org.hibernate.type.BinaryType@63070bab
lis 25, 2016 9:43:29 AM org.hibernate.type.BasicTypeRegistry register
INFO: HHH000270: Type registration [Byte[]] overrides previous : org.hibernate.type.WrapperBinaryType@2d2ffcb7
lis 25, 2016 9:43:29 AM org.hibernate.type.BasicTypeRegistry register
INFO: HHH000270: Type registration [[Ljava.lang.Byte;] overrides previous : org.hibernate.type.WrapperBinaryType@2d2ffcb7
DOC_ID= 0
lis 25, 2016 9:43:29 AM org.hibernate.hql.internal.QuerySplitter concreteQueries
WARN: HHH000183: no persistent classes found for query class: from DOCUMENT where doc_firm_id= 317989
lis 25, 2016 9:43:29 AM org.hibernate.hql.internal.QueryTranslatorFactoryInitiator initiateService
INFO: HHH000397: Using ASTQueryTranslatorFactor