|
Project Information
Featured
Downloads
Links
|
MavenHibernate-Sqlite maven use1.add repository in the pom.xml file(between the repositories tag) <repository> <id>hibernatesqlite-maven</id> <url>https://hibernate-sqlite.googlecode.com/svn/trunk/mavenrepo</url> </repository> 2.add dependency in the pom.xml file(between the dependencies tag) <!-- hibernate sqlite dialect --> <dependency> <groupId>com.applerao</groupId> <artifactId>hibernatesqlite</artifactId> <version>1.0</version> </dependency> 3.modify the hibernate dialect configuration like: <property name="dialect">com.applerao.hibernatesqlite.dialect.SQLiteDialect</property> 4.maven your project and the hibernate-sqlite is ready to use. <!-- hibernate sqlite dialect --> <dependency> <groupId>com.applerao</groupId> <artifactId>hibernatesqlite</artifactId> <version>1.0</version> <exclusions> <exclusion> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> </exclusion> </exclusions> </dependency> and add hibernate dependency like this: <!-- hibernate jars --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.2.7.ga</version> </dependency> Besides, you can just add a hibernate dependency to override without exclude it in the hibernatesqlite dependency. DownloadLocal Project1.http://hibernate-sqlite.googlecode.com/files/HibernateSQLite.rar Web Project1.http://hibernate-sqlite.googlecode.com/files/HSWeb.rar Before run the web project,read the readme.txt to configure the database connectionhttp://hibernate-sqlite.googlecode.com/files/readme.txt SQLite with HibernateSince SQLite database is widely used and it is not well supported by Hibernate(not NHibernate) in java,it's not easy to use SQLite with Hibernate.This project is to help you quickly start with SQLite-Hibernate programming. Guide to quickly start with the demo project1.Download the HibernateSQLite ProjectHibernateSQLite Project,download it here: http://hibernate-sqlite.googlecode.com/files/HibernateSQLite.rar,then go to the second step. 2.Build the project with Maven2After you have Unziped it, use maven2 to build the project. If you haven't installed Maven2, go to http://maven.apache.org/download.html to download one and install it.Then,Enter the project folder in command window, such as: C:\Documents and Settings\Administrator>f: F:\>cd work F:\work>cd workspace F:\work\workspace>cd HibernateSQLite F:\work\workspace\HibernateSQLite> execute the maven2 command "mvn eclipse:clean", like this: F:\work\workspace\HibernateSQLite>mvn eclipse:clean after you have cleaned the project, execute the command "mvn eclipse:eclipse", like this: F:\work\workspace\HibernateSQLite>mvn eclipse:eclipse if the command window displays like this: [INFO] ------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------ [INFO] Total time: 6 seconds [INFO] Finished at: Fri Jan 02 20:49:32 CST 2009 [INFO] Final Memory: 6M/11M [INFO] ------------------------------------------ then the project is build sucessfully. 3.Import the project into EclipseIn Eclipse, choose "Import --> Existing Projects into Workspace", browse the demo project folder and click "OK", then choose "HibernateSQLite", and the demo project is successfully imported into eclipse workspace. 4.Test the demo project is working wellRun the Junit TestCase "TestSaveUser.java" under package "test" to test if the project works well.The propose result is: Hibernate:
insert
into
users
(name, password)
values
(?, ?)
Hibernate:
select
last_insert_rowid()if so,the demo is already working well.With this demo, you can easyly produce code using SQLite DataBase with Hibernate. Introduction of Demo Project1.CatalogHibernateSQLite
|-- pom.xml
`-- src
|-- main
| |-- java
| | |-- dialect
| | | `-- SQLiteDialect.java
| | |-- model
| | | `-- User.java
| | `-- util
| | `-- HibernateUtil.java
| |
| |
| `-- resources
| |-- hibernate.cfg.xml
| |-- log4j.properties
| `-- User.hbm.xml
|
`-- test
`-- java
`-- test
`-- TestSaveUser.java2.Referenced Jarspom.xml <dependencies> <!-- Junit Test --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.5</version> <scope>test</scope> </dependency> <!-- Hibernate --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.2.6.ga</version> </dependency> <dependency> <groupId>antlr</groupId> <artifactId>antlr</artifactId> <version>2.7.6</version> </dependency> <dependency> <groupId>asm</groupId> <artifactId>asm</artifactId> <version>1.5.3</version> </dependency> <dependency> <groupId>c3p0</groupId> <artifactId>c3p0</artifactId> <version>0.9.1</version> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>2.1_3</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2</version> </dependency> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.9</version> </dependency> <dependency> <groupId>ehcache</groupId> <artifactId>ehcache</artifactId> <version>1.2.3</version> </dependency> <dependency> <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <version>1.1</version> </dependency> <!-- SQLite database JDBC --> <dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> <version>3.6.0</version> </dependency> </dependencies> 3.Usage
|