-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Logging problem?????
PostPosted: Wed Jun 08, 2005 5:22 am 
Newbie

Joined: Thu May 12, 2005 12:01 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: hibernate 2.0.3

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="address">
<class
name="Address"
table="ADDR"
>
<id name="MAC" type="java.lang.String" unsaved-value="null" >
<column name="MAC" sql-type="VARCHAR"
not-null="false"/>
<generator class="assigned"/>

</id>
<property name="IPv4" column="IPv4" type="java.lang.String" />
<property name="IPv6" column="IPv6" type="java.lang.String"/>



</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
package address.main;

import java.util.ArrayList;
import java.util.Random;

import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import net.sf.hibernate.Session;
import address.Address;
import address.dao.AddressDAO;
import address.util.HibernateUtil;

/** Test class for address book */
public class AddrTest extends TestCase {

private String mac;

private Address address;

private String ipv6;

private String ipv4;

private long t1;
private long t2;

private long tt1;
private long tt2;

private Address address1;

private Address addressMid;

private Address addressLast;

ArrayList addrList = new ArrayList();

//int number = 100000;
int number = 100;
/** constructor */
public AddrTest(String x) {
super(x);
}

/** create test suite */
public static Test suite() {
return new TestSuite(AddrTest.class);
}

private final Random rnd = new Random();

private char cr;

/** function to get char 0-9 and A-F*/
public char getNextChar() {
int cr = 0;

while (!((cr >= 48 && cr < 57) || (cr >= 65 && cr < 70))) {
cr = rnd.nextInt(70);
}

return (char) cr;

}

/** initialize data */
private void initData() {
HibernateUtil.beginTransaction();
Session s = HibernateUtil.getSession();
//AddressDAO addressDAO = new AddressDAO();
for (int i = 0; i < number; i++) {
String mac = new String(getNextChar() + "")
+ new String(getNextChar() + "-");
mac += new String(getNextChar() + "")
+ new String(getNextChar() + "-");
mac += new String(getNextChar() + "")
+ new String(getNextChar() + "-");
mac += new String(getNextChar() + "")
+ new String(getNextChar() + "-");
mac += new String(getNextChar() + "")
+ new String(getNextChar() + "-");
mac += new String(getNextChar() + "")
+ new String(getNextChar() + "");

Address addr = new Address(mac, "10.207.130.5", "10.207.128.3");
addrList.add(addr);
if (i == 0)
address1 = addr;
if (i == (int) number / 2)
addressMid = addr;
if (i == number - 1)
addressLast = addr;

}
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();
}

/** insert data */
public void testAddr() throws Exception {
long total = 0;

initData();
// query operation for entry
HibernateUtil.beginTransaction();
Session s = HibernateUtil.getSession();
// start time

AddressDAO addressDAO = new AddressDAO();
tt1 = System.currentTimeMillis();
for (int i = 0; i < number; i++) {
t1 = System.currentTimeMillis();
addressDAO.save((Address) addrList.get(i), s);
// finish time
t2 = System.currentTimeMillis();

// Used time =finish time - start time
long d = t2 - t1;
total += d;
// System.out.print(d + "ms, ");
}
tt2 = System.currentTimeMillis();
System.out.println("\nTotal Time = " + total + " ms ");//total of used time for one process
System.out.println("Avg Time = " + (total / number) + " ms "); //average of used timefor one process
System.out.println("\nTotal Time = " + (tt2-tt1) + " ms ");//total of used time for all process
System.out.println("Avg Time = " + ((tt2-tt1) / number) + " ms ");//average of used timefor all process
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();
}

public void testRecord() throws Exception {

long total = 0;

initData();
/**query operation for entry*/
HibernateUtil.beginTransaction();
Session s = HibernateUtil.getSession();

AddressDAO addressDAO = new AddressDAO();


/** get first record */

t1 = System.currentTimeMillis();// start time

addressDAO.get(address1.getMAC(), s);

t2 = System.currentTimeMillis();// finish time

System.out.println("Time (first ) " + address1.getMAC() + " = "
+ (t2 - t1) + " ms ");


/** get median record */
t1 = System.currentTimeMillis();// start time

addressDAO.get(addressMid.getMAC(), s);

t2 = System.currentTimeMillis();// finish time

System.out.println("Time ( median) " + addressMid.getMAC() + " = "
+ (t2 - t1) + " ms ");


/** get last record */
t1 = System.currentTimeMillis();// start time

addressDAO.get(addressLast.getMAC(), s);
t2 = System.currentTimeMillis();// finish time

long d2 = t2 - t1;// Used time =finish time - start time

System.out.println("Time( last ) " + addressLast.getMAC() + " = "
+ (t2 - t1) + " ms ");

/** get total time for record */

tt1 = System.currentTimeMillis();
for (int i = 0; i < number; i++) {
t1 = System.currentTimeMillis(); //start time
addressDAO.get(((Address) addrList.get(i)).getMAC(), s);
t2 = System.currentTimeMillis();// finish time
long d = t2 - t1;// Used time =finish time - start time
total += d;
}
tt2 = System.currentTimeMillis();
System.out.println("\nTotal Time = " + total + " ms ");
System.out.println("Avg Time = " + (total / number) + " ms ");
System.out.println("\nTotal Time = " + (tt2-tt1) + " ms ");
System.out.println("Avg Time = " + ((tt2-tt1) / number) + " ms ");

HibernateUtil.commitTransaction();
HibernateUtil.closeSession();
}

/** run test */
public static void main(String[] args) throws Exception {
TestRunner.run(suite());
}

}


Full stack trace of any exception that occurs:

Name and version of the database you are using:
Hsqldb 1.7.1

The generated SQL (show_sql=true):
/*C6*/CONNECT USER SA
SET AUTOCOMMIT FALSE
/*C7*/CONNECT USER SA
SET AUTOCOMMIT FALSE
SET AUTOCOMMIT TRUE
drop table ADDR if exists
create table ADDR (MAC VARCHAR, IPv4 VARCHAR(255), IPv6 VARCHAR(255), primary key (MAC))
DISCONNECT
/*C6*/INSERT INTO ADDR VALUES('D3-5B-5E-03-7E-62','10.207.130.5','10.207.128.3')
INSERT INTO ADDR VALUES('81-85-7E-E5-28-13','10.207.130.5','10.207.128.3')
INSERT INTO ADDR VALUES('8B-8D-A6-DE-77-8B','10.207.130.5','10.207.128.3')
INSERT INTO ADDR VALUES('60-11-AA-AA-83-51','10.207.130.5','10.207.128.3')
INSERT INTO ADDR VALUES('50-15-C7-51-D5-62','10.207.130.5','10.207.128.3')
INSERT INTO ADDR VALUES('4E-C6-88-2C-32-73','10.207.130.5','10.207.128.3')
INSERT INTO ADDR VALUES('50-45-1E-71-70-DC','10.207.130.5','10.207.128.3')
INSERT INTO ADDR VALUES('87-D1-86-6A-B6-E4','10.207.130.5','10.207.128.3')
INSERT INTO ADDR VALUES('8D-03-4A-81-CB-03','10.207.130.5','10.207.128.3')
INSERT INTO ADDR VALUES('88-2E-C3-57-55-75','10.207.130.5','10.207.128.3')
COMMIT
/*C8*/CONNECT USER SA
SET AUTOCOMMIT FALSE
SET AUTOCOMMIT TRUE
drop table ADDR if exists
DISCONNECT
/*C9*/CONNECT USER SA
SET AUTOCOMMIT FALSE
SET AUTOCOMMIT TRUE
drop table ADDR if exists
create table ADDR (MAC VARCHAR, IPv4 VARCHAR(255), IPv6 VARCHAR(255), primary key (MAC))
DISCONNECT
/*C10*/CONNECT USER SA
SET AUTOCOMMIT FALSE
SET AUTOCOMMIT TRUE
drop table ADDR if exists
DISCONNECT

Debug level Hibernate log excerpt:
.Jun 8, 2005 5:14:06 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.2
Jun 8, 2005 5:14:06 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Jun 8, 2005 5:14:06 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Jun 8, 2005 5:14:06 PM net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jun 8, 2005 5:14:06 PM net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Jun 8, 2005 5:14:07 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: address/Address.hbm.xml
Jun 8, 2005 5:14:07 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: address.Address -> ADDR
Jun 8, 2005 5:14:08 PM net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Jun 8, 2005 5:14:08 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jun 8, 2005 5:14:08 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jun 8, 2005 5:14:08 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jun 8, 2005 5:14:08 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.HSQLDialect
Jun 8, 2005 5:14:08 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: false
Jun 8, 2005 5:14:08 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Jun 8, 2005 5:14:08 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Jun 8, 2005 5:14:08 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:file:E:\test3\db\new
Jun 8, 2005 5:14:08 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sa, password=}
Jun 8, 2005 5:14:08 PM net.sf.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
Jun 8, 2005 5:14:08 PM net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
Jun 8, 2005 5:14:08 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
Jun 8, 2005 5:14:08 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): false
Jun 8, 2005 5:14:08 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
Jun 8, 2005 5:14:08 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Jun 8, 2005 5:14:08 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.ehcache.hibernate.Provider
Jun 8, 2005 5:14:08 PM net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
Jun 8, 2005 5:14:09 PM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Jun 8, 2005 5:14:10 PM net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: no JNDI name configured
Jun 8, 2005 5:14:10 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.HSQLDialect
Jun 8, 2005 5:14:10 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jun 8, 2005 5:14:10 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jun 8, 2005 5:14:10 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jun 8, 2005 5:14:10 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jun 8, 2005 5:14:10 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jun 8, 2005 5:14:10 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jun 8, 2005 5:14:10 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: Running hbm2ddl schema export
Jun 8, 2005 5:14:10 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database
Jun 8, 2005 5:14:10 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Jun 8, 2005 5:14:10 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Jun 8, 2005 5:14:10 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:file:E:\test3\db\new
Jun 8, 2005 5:14:10 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sa, password=}
Jun 8, 2005 5:14:10 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: schema export complete
Running test...
Jun 8, 2005 5:14:10 PM net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:hsqldb:file:E:\test3\db\new
Jun 8, 2005 5:14:10 PM net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:hsqldb:file:E:\test3\db\new

un 8, 2005 5:14:10 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.HSQLDialect
Jun 8, 2005 5:14:10 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jun 8, 2005 5:14:10 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jun 8, 2005 5:14:10 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jun 8, 2005 5:14:10 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jun 8, 2005 5:14:11 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: Running hbm2ddl schema export
Jun 8, 2005 5:14:11 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:file:E:\test3\db\new
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sa, password=}
Jun 8, 2005 5:14:11 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: schema export complete
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:hsqldb:file:E:\test3\db\new
.Jun 8, 2005 5:14:11 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.HSQLDialect
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jun 8, 2005 5:14:11 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: Running hbm2ddl schema export
Jun 8, 2005 5:14:11 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:file:E:\test3\db\new
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sa, password=}
Jun 8, 2005 5:14:11 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: schema export complete
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:hsqldb:file:E:\test3\db\new
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:hsqldb:file:E:\test3\db\new
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:hsqldb:file:E:\test3\db\new
Running test...
Jun 8, 2005 5:14:11 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.HSQLDialect
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Jun 8, 2005 5:14:11 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Jun 8, 2005 5:14:11 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: Running hbm2ddl schema export
Jun 8, 2005 5:14:11 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)

Time: 4.562

OK (2 tests)

Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:file:E:\test3\db\new
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sa, password=}
Jun 8, 2005 5:14:11 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: schema export complete
Jun 8, 2005 5:14:11 PM net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:hsqldb:file:E:\test3\db\new




Does anyone know how to disable Hibernate log to show in console??

thanks you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.