Yonatan K
Yonatan K

Reputation: 620

Troubles with Hibernate configuration with H2

I'm trying to configure Hibernate to work over H2, but when i call:
Configuration cfg = new Configuration().configure();
the call for new Configuration() outputs the following:
מאי 01, 2012 5:10:41 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
מאי 01, 2012 5:10:41 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.1}
מאי 01, 2012 5:10:41 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
מאי 01, 2012 5:10:41 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist

But this doesn't stop execution... After this, the call to .configure() outputs:
מאי 01, 2012 5:14:39 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
מאי 01, 2012 5:14:39 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
מאי 01, 2012 5:14:39 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null

What does these messages mean?

hibernate.cfg.xml:

<session-factory>

    <!-- Database connection settings -->
    <property name="connection.driver_class">org.h2.Driver</property>
    <property name="connection.url">jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE</property>
    <property name="connection.username">user</property>
    <property name="connection.password">password</property>

    <!-- JDBC connection pool (use the built-in) -->
    <property name="connection.pool_size">1</property>

    <!-- SQL dialect -->
    <property name="dialect">org.hibernate.dialect.H2Dialect</property>

    <!-- Disable the second-level cache  -->
    <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>

    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">true</property>

    <!-- Drop and re-create the database schema on startup -->
    <property name="hbm2ddl.auto">create</property>

    <!-- Names the annotated entity class -->
    <mapping class="database.datatypes.Course"/>
    <mapping class="database.datatypes.Distance"/>
    <mapping class="database.datatypes.ExamRange"/>
    <mapping class="database.datatypes.NumExamsOnDate"/>
    <mapping class="database.datatypes.RecommendedSchedule"/>

</session-factory>

One of the classes representing a table:

@Entity public class Distance {

private Course courseA, courseB;
private Long MinDistance, Cost;

@Id
@GeneratedValue(generator="increment")
@GenericGenerator(name="increment", strategy = "increment")
private Long id;


public Distance() {
    super();
}

public Distance(Course courseA, Course courseB, Long minDistance, Long cost) {
    super();
    this.courseA = courseA;
    this.courseB = courseB;
    MinDistance = minDistance;
    Cost = cost;
}


@Override
public String toString() {
    return "Distance [courseA=" + courseA + ", courseB=" + courseB
            + ", MinDistance=" + MinDistance + ", Cost=" + Cost + "]";
}

public Course getCourseA() {
    return courseA;
}

public void setCourseA(Course courseA) {
    this.courseA = courseA;
}

public Course getCourseB() {
    return courseB;
}

public void setCourseB(Course courseB) {
    this.courseB = courseB;
}

public Long getMinDistance() {
    return MinDistance;
}

public void setMinDistance(Long minDistance) {
    MinDistance = minDistance;
}

public Long getCost() {
    return Cost;
}

public void setCost(Long cost) {
    Cost = cost;
}

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

}

Thank you.

Upvotes: 0

Views: 4637

Answers (1)

kyiu
kyiu

Reputation: 1976

As you can see, the messages you mentioned are from INFO level. Messages from this logging level usually lets you know what the underlying framework (here, Hibernate) is doing. So, in that case, everything's fine. If you think theses messages are too disturbing, just change the logging level to something like WARN.

Upvotes: 1

Related Questions