Instalasi PATH JAVA di Windows

Instalasi PATH JAVA di Windows

computer ->control panel -> advanced system setting -> advenced -> PILIH Environments variable

variable name: CLASSPATH

variable value: C:\Program Files\Java\jdk1.8.0_60\lib\tools.jar;,

variable name: HOME

variable value: C:\Program Files\Java\jdk1.8.0_60;,

variable name: PATH

variable value: C:\Program Files\Java\jdk1.8.0_60\bin;,

PATH java


csv issue

manipulates content field from db into csv file format
this is a case from enum and then showing the char in csv
example 1

List<Object[]> results = query.getResultList();

        for (Object[] item : results) {

            for (Object object : item) {

                //change a status to 'char'
                    if (object.equals(0)){
                        csvResult.append("Junior High Student").append(',');
                    } else if(object.equals(1)){
                        csvResult.append("Senior High Student").append(',');
                    } else if(object.equals(2)){
                        csvResult.append("Diplouma Student").append(',');
                    } else if(object.equals(3)){
                        csvResult.append("Bachelor Student").append(',');
                    } else if(object.equals(4)){
                        csvResult.append("MSc Student").append(',');
                    } else if(object.equals(5)){
                        csvResult.append("Doctor Student").append(',');
                    } else {

                else {

            csvResult.deleteCharAt(csvResult.length() - 1);

changes value ‘null’ to string
example 2

                    if(object== null){
                    } else if(object != null) {
                    } else {

JEE-persistence API (JPA)

JEE/ Java enterprise edition

JPA Java persistence

@CollectionTable is used to mapping of collections of basic or embeddable types.@Entity is allows collections of simple objects to be easily defined.

The entity’s persistent state is defined by four field, the identity id defined by the field id and is annotated with @id. A composite primary key may also be defined where the primary key corresponds to ome or more fields of the entity class. 

the implements  Serializable interface, and that allows it to be passed by value through a remote interface.

The relationships between different entities are defined using @OneToOne, @OneToMany, @ManyToOne and @ManyToMany annotation on the corresponding field of the referencing entity.

Validating the Entities.

validation has some predefined constraints like @Min, @Max, @Pattern and @Size.

public class Student implements serializable {

private int id;

private String name;

@Size(min=3, max=10)
private String grade;

protected String email;