Back to directory
j256 avatar

ormlite-core

Core ORMLite functionality that provides a lite Java ORM in conjunction with ormlite-jdbc or ormlite-android. Read more below about its uses, features, and usage.

Clone repository

git clone https://github.com/j256/ormlite-core.git

604

Stars

213

Forks

35

Watchers

ISC

License

ORMLite Core

This package provides the core functionality for the JDBC and Android packages. Users that are connecting to SQL databases via JDBC should download the ormlite-jdbc package instead which includes these core classes. Android users should download the ormlite-android package instead which also includes these core classes.

ORMLite is easy to use and provides the following features:

Enjoy, Gray Watson

Code Example

The following is a quick code example to give you a taste on how to use the library.

// this uses h2 but you can change it to match your database
String databaseUrl = "jdbc:h2:mem:account";
// create a connection source to our database
ConnectionSource connectionSource = new JdbcConnectionSource(databaseUrl);

// instantiate the DAO to handle Account with String id
Dao<Account,String> accountDao = DaoManager.createDao(connectionSource, Account.class);

// if you need to create the 'accounts' table make this call
TableUtils.createTable(connectionSource, Account.class);

// create an instance of Account
String name = "Jim Smith";
Account account = new Account(name, "_secret");

// persist the account object to the database
accountDao.create(account);

// retrieve the account
Account account2 = accountDao.queryForId(name);
// show its password
System.out.println("Account: " + account2.getPassword());

// close the connection source
connectionSource.close();

Logging Information

ORMLite has copied in logging code from SimpleLogging which backends to a number of different logging systems and is configurable via code or configuration. For more details see the logging documentation.

Maven Configuration

For JDBC usage, you should depend on Maven Central which includes the core classes.

<dependency>
	<groupId>com.j256.ormlite</groupId>
	<artifactId>ormlite-jdbc</artifactId>
	<version>6.1</version>
</dependency>

For Android usage, you should depend on Maven Central which includes the core classes.

<dependency>
	<groupId>com.j256.ormlite</groupId>
	<artifactId>ormlite-android</artifactId>
	<version>6.1</version>
</dependency>

ChangeLog Release Notes

See the ChangeLog.txt file.

Releases

ALL: Bumped the optional dependency to log4j2 to version 2.17.0. No direct references to log4j2 code in ormlite.

ALL: Added support for Java 7. Dropped support for Java 6. ALL: Migrated to supporting AutoCloseable. Most close() methods now throw Exception not IOException. CORE: Removed some deprecated methods...

CORE: Fixed possible thread issue around field-name lookups. Thanks to dlew. CORE: Fixed a number of flaky tests based on field order. Thanks CharlesZKQ, NanaOkada, hwang-pku, and chimo173. CORE: Upg...

CORE: Added support for @entity storing of Serializable types. Thanks to arn-cpu. CORE: Fixed a bug with nonreentrant handling of DateFormat. Thanks to Bob Lacatena. ANDROID: Removed the reflection...

CORE: Added support for java.util.Currency. Thanks for juur. ANDROID: Fixed bug in AndroidLogBackend. Thanks to sanderderks.