I'm in need of help with hibernate annotation, when I have a table with same parent id.
Like this example
CREATE TABLE `server` (
`server` int(11) DEFAULT NULL,
`name` va开发者_开发技巧rchar(20) DEFAULT NULL,
`parentid` int(11) DEFAULT NULL,
KEY `parentid` (`parentid`),
KEY `server` (`server`),
CONSTRAINT `server_fk` FOREIGN KEY (`parentid`) REFERENCES `server` (`server`)
);
Output like this
Server A
Server B
Server C
Server D
Server E
Server C
Server D
Server F
Server G
How can I map this in my Class
@Entity
public class Server {
@Id @GeneratedValue
private Long id;
private String name, description;
private Server parentid;
}
精彩评论