WSK
WSK

Reputation: 6198

How to define transient property in hibernate?

I am using separate hbm.xml files for hibernate mappings and facing problem in defining transient property. I spent several hours without luck to search a working example or writing my own.
Can somebody help me make a property transient through hbm.xml (if possible) because it will keep my application consistent. If not possible through hbm.xml then though annotation mized with xml. Any link to existing docs or thread are welcomed.

My sample mapping class is:

<class name="Test">
    <id name="a" type="long">
        <generator class="identity" />
    </id>
    <property name="b" type="string" />
    <property name="c" type="string" />
</class>

and sample entity class is:

public class Test {
    private Long a;
    private String b;
    private String c;

    public void setA(Long a) { this.a = a; }
    public Long getA() { return a; }

    public void setB(String b) { this.b = b; }
    public String getB() { return b; }

    public void setC(String c) { this.c = c; }
    public String getC() { return c; }
}

Upvotes: 1

Views: 6624

Answers (1)

Ryan Stewart
Ryan Stewart

Reputation: 128919

"make a property transient through hbm.xml"? You mean have a property not mapped to the database? Just don't map it.

Upvotes: 9

Related Questions