Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Java by irange ( 13 years ago )
@NamedQueries({
        @NamedQuery(name="category.ByName", query="SELECT c from Category c where c.name = :name"),
        @NamedQuery(name="Category.getTopics", query="SELECT t FROM Topic t inner join Category c WHERE t.category.id = :categoryId")
})

public class Category extends GlobalTable implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @SequenceGenerator(name = "Category_SEQ", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "Category_SEQ")
    private int id;
    
    @Column(name = "name", nullable = false, length = 50)
    private String name;

    @Column(name = "description", nullable = false, columnDefinition = "TEXT")
    private String description;

    @ManyToOne
    private Forum forum;

    @OneToMany(targetEntity = Topic.class, mappedBy = "category")
    private Collection topics;
.........................


public class Topic extends GlobalTable implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @SequenceGenerator(name="Topic_SEQ", allocationSize=1)
    @GeneratedValue(strategy = GenerationType.AUTO, generator="Topic_SEQ")
    private int id;

    @Column(name="name",nullable=false, length=50)
    private String name;

    @Column(name="description",nullable=false,columnDefinition="TEXT")
    private String description;
    
    @Column(name="type",nullable=false)
    private int type;
    
    @ManyToOne
    private User user;

    @ManyToOne(targetEntity=Category.class)
    private Category category;

 

Revise this Paste

Your Name: Code Language: