Showing posts with label Hibernate. Show all posts
Showing posts with label Hibernate. Show all posts

java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder

0

Posted by Jagadeesh VP | Posted in

In hibernate this error is common.

Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)

The hibernate distribution package have slf4j-api-x.x.x.jar file which does not have the impl package.

To avoid this error download slf4j-x.x.x.zip / .gz package from http://slf4j.org/download.html.

In this package you will find slf4j-simple-x.x.x.jar which has this org.slf4j.impl package. Add this jar in your classpath and run your application.

Hibernate Manny-to-Many Mapping

0

Posted by Jagadeesh VP | Posted in


package com.vpj;

import java.util.Set;
import com.vpj.Boo;

public class Foo {
private String fooId;
private Storing name;

private Set<Boo> boo;

/* Getters & Setters */
}

package com.vpj;

import java.util.Set;
import com.vpj.Foo;

public class Boo {
private String booId;
private String name;

private Set<Foo> foo;

/* Getters & Setters */
}

.hbm.xml :

...
<class type="com.vpj.Foo">
<id name="id" column="id">
<genetator class="increment" />
</id>

<property name="name" type="string" column="name" />

<set name="boo" table="Foo_Boo">
<key column="fooId" />
<many-to-many column="booId" class="Boo" />
</set>
</class>

<class type="com.vpj.Boo">
<id name="id" column="id">
<generator class="increment" />
</id>

<property name="name" type="string" column="name" />

<set name="foo" table="Foo_Boo">
<key column="booId" />
<many-to-many column="fooId" class="Foo" />
</set>
</class>
...