开发者

hibernate mapping for Object

public class ID {
    protected String name;
    protected Object id;
}

How c开发者_高级运维an I map the above class in hibernate, if I were to use ID.hbm.xml ? Is this possible ?


Instead of using xml, you can use annotations:

@Entity
public class ID {
    @Id
    private Object id;
    @Column
    private String name;
    // getters and setters
}

Btw, ID is a strange name for an entity.

In XML you would need something like this (reference):

<class ...>
    <id .. />
    <property .. />
</class>

The type of the id field depends entirely on your requirements - most often it is an auto-generated int (using the @GeneratedValue annotation). But it can be a String, or any manually-assigned, database-persistable type.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜