开发者

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; }
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜