Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
- <hibernate-configuration>
- <session-factory>
- <property name="hibernate.connection.driver_class">org.sqlite.JDBC</property>
- <property name="hibernate.connection.url">jdbc:sqlite:stuff.db</property>
- <property name="hibernate.dialect">com.enigmabridge.hibernate.dialect.SQLiteDialect</property>
- <property name="hibernate.hbm2ddl.auto">create</property>
- <property name="hibernate.show_sql">true</property>
- <mapping resource="stuff/Stuff.hbm.xml"/>
- </session-factory>
- </hibernate-configuration>
- package stuff;
- public class Stuff {
- private Integer id;
- private String stuff;
- public Stuff() {
- }
- public Stuff(String stuff) {
- this.stuff = stuff;
- }
- public Integer getId() {
- return id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
- public String getStuff() {
- return stuff;
- }
- public void setStuff(String stuff) {
- this.stuff = stuff;
- }
- @Override
- public String toString() {
- return "Stuff{" + "id=" + id + ", stuff=" + stuff + '}';
- }
- }
- <hibernate-mapping>
- <class name="stuff.Stuff" table="stuff">
- <id name="id" type="integer" column="id">
- <generator class="increment"/>
- </id>
- <property name="stuff" type="string" column="stuff"/>
- </class>
- </hibernate-mapping>
- package stuff;
- import java.util.List;
- import org.hibernate.Query;
- import org.hibernate.Session;
- public class Main {
- public static void main(String[] args) {
- Session session = HibernateUtil.getSessionFactory().openSession();
- session.beginTransaction();
- session.save(new Stuff("blah blah"));
- //Query q = s.createQuery("select from Stuff");
- //List<Stuff> l = q.list();
- //for (Stuff s:l)System.out.println(s);
- session.getTransaction().commit();
- session.close();
- System.exit(0);
- }
- }
Add Comment
Please, Sign In to add comment