views:

38

answers:

3

I have a table tbl_sky that has 2 properties name and model and I would use Hibernate annotation like;

@Entity
@Table(name="tbl_sky")
public class Sky implements Serializable {
    private String name;
    private String model;
    private String status;

    @Id
    public String getName() {
        return name;
    }
.
.
.

But I need to add one more property status that does not exist in the table but is needed in the class. How could I declare that property so that I have it in my class but not in my db-table?

All help is appreciated.

+6  A: 

Use @Transient annotation for field you are not going to store in DB:

@Transient
public String getStatus() {
    return status;
}

or:

@Transient
private String status;
Kel
it can go on the getter, or on the field itself.
Bozho
Thanks, updated answer
Kel
+2  A: 

If you annotate a field with @Transient it will not be persisted.

jjungnickel
thanx @jjungnickel
Adnan
+1  A: 

Mark it as @Transient, and it won't be part of the DB schema.

seanizer