Skip to content
restarac edited this page Mar 8, 2013 · 4 revisions

Let's go on the tutorial, need basically 3 steps:

First: Chosing Entity

Choose an entity, this entity need to are an entity capable to persist on database using the JPA 2.0;

We'll do this example, using this simples entity:

@Entity
public class Product implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    //Constructors and getters/Setters
}

Second: Get the jar

Access path on the repository: reflection-entity/non-maven/dist/ (Link to Folder)

In that folder you'll see the jar reflection-entity.jar. Download it, and add the classpath on yours project. (The project was builded on netbeans 7.2, and on netbeans is generated an ant build and building the application is generated this jar.)

Second: Use it!

To finalize, use the class ReflectionEntity to do your magic. So if is the first verion, and more verions are comming.

That is an exemple to use it:

public class Test {
        public static void main(String[] args) {
        final Product product = new Product();
        product.setId(1);
        String result = ReflectionEntity.entityToString(product);
        System.out.println("ToString: "+result);
    }
}

And this is the result:

run:
ToString: Product[PK(id='1')]
BUILD SUCCESSFUL (total time: 0 seconds)

Well, how i said before this is the first version.

Clone this wiki locally