Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.j256.ormlite.examples.manytomany;
 
Join table which links users to their posts.

For more information about foreign objects, see the online docs

public class UserPost {
	public final static String USER_ID_FIELD_NAME = "user_id";
	public final static String POST_ID_FIELD_NAME = "post_id";

This id is generated by the database and set on the object when it is passed to the create method. An id is needed in case we need to update or delete this object in the future.
	@DatabaseField(generatedId = true)
	int id;
	// This is a foreign object which just stores the id from the User object in this table.
	@DatabaseField(foreign = true, columnName = )
	// This is a foreign object which just stores the id from the Post object in this table.
	@DatabaseField(foreign = true, columnName = )
		// for ormlite
	}
	public UserPost(User userPost post) {
		this. = user;
		this. = post;
	}
New to GrepCode? Check out our FAQ X