Jerry Jacob's Blog

Own ID Column for the Model in the Play! Framework

Posted in Java/ J2EE, Play Framework by Jerry Jacob on January 11, 2012

When you create Model entities in the Play! Framework, Play will provide a default id column.  If you need to use your own id column — say if you are given a database schema to work with — then you should extend a different Play class called GenericModel instead of Model class.  In addition to providing an @Id annotation, it also provides @GeneratedValue annotation. Here is its usage both with  Oracle and MySql.

public class Tutorial extends GenericModel {
@GeneratedValue(strategy = GenerationType.AUTO)
public Long tutorial_id;


@GeneratedValue(strategy=SEQUENCE, generator="videoIdSeq")
@SequenceGenerator(name="videoId", sequenceName="video_id_seq", allocationSize=1)
protected Long videoId;

Create zip files in Java

Posted in Java/ J2EE by Jerry Jacob on January 11, 2012

The output of the below Java program will be the creation of a zip file inside c:/ with the name
Taken from

package com.example;
/** This class is a Java tutorial for creating zip file
 * @author Extreme Java
public class Test{
	/** The method creates zip file and also creates an entry inside it
	 * @param args is the command line arguments
	 * @throws IOException 
	public static void main(String[] args) throws IOException  {
		//create a file output stream
		FileOutputStream zipFOS = new FileOutputStream("c://");
		//create a zip output stream from the file output stream created above.
		//zip output stream decorates file output stream
		ZipOutputStream zipoutStream = new ZipOutputStream(zipFOS);
		//creates an zip entry. You can create as many entries as you wish
		//Each entry represent a file with in the zip archive
		ZipEntry zipEntry = new ZipEntry("source1");
		//put the zip entry create above into the zip file
		//write some text into the zip entry created above.
		//Whatever is written will be added to last added zip entry
		//close the zip entry.
		//Finish the creation of zip file.
		//close the file output stream
		//close the zip output stream