Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.j256.ormlite.examples.datapersister;
 
 import java.util.Date;
 
 
Example user object that is persisted to disk by the DAO and other example classes.
public class User {
	// for UpdateBuilder to be able to find the fields
	public static final String FIELD_BIRTH_DATE = "birthDate";
	@DatabaseField(generatedId = true)
	private int id;
	private String name;

We use the persisterClass here to use our customer persister for handling invalid SQL Timestamp values.
	@DatabaseField(columnName = , persisterClass = MyDatePersister.class)
	private Date birthDate;

NOTE: this is _not_ a default type that is stored by ORMLite so we are going to define a custom persister for org.joda.time.DateTime and register it using com.j256.ormlite.field.DataPersisterManager.registerDataPersisters(com.j256.ormlite.field.DataPersister[]).
	User() {
		// all persisted classes must define a no-arg constructor with at least package visibility
	}
	public User(String nameDate birthDateDateTime createDateTime) {
		this. = name;
		this. = birthDate;
		this. = createDateTime;
	}
	public int getId() {
		return ;
	}
	public String getName() {
		return ;
	}
	public Date getBirthDate() {
		return ;
	}
	}
New to GrepCode? Check out our FAQ X