[jboss-user] [EJB 3.0] - Re: Bug of Persistence API?
Seto
do-not-reply at jboss.com
Fri Nov 3 04:19:12 EST 2006
here is the code of the Article
| /**
| *
| */
| package cn.net.kdc.domain.cms;
|
| import java.util.*;
|
| import javax.persistence.*;
|
| import org.hibernate.validator.*;
|
| import cn.net.kdc.domain.global.*;
|
| /**
| * @author Seto
| *
| */
| @Entity
| @Table(name = "cms_article")
| public class Article {
| @Id
| @GeneratedValue
| @Column(name = "id")
| private int id;
|
| @Column(name = "tag")
| @NotNull
| @Length(min = 2, max = 8)
| private String tag;
|
| @Column(name = "title")
| @NotNull
| @Length(min = 4, max = 32)
| private String title;
|
| @Column(name = "short_title")
| @NotNull
| @Length(min = 4, max = 32)
| private String short_title;
|
| @Column(name = "long_title")
| @NotNull
| @Length(min = 4, max = 32)
| private String long_title;
|
| @Column(name = "author")
| @Length(min = 4, max = 64)
| private String author;
|
| @Column(name = "click_count")
| private int click_count;
|
| @Column(name = "insert_date")
| @NotNull
| @Temporal(TemporalType.TIME)
| private Date insert_date = new Date();
|
| @Column(name = "update_date")
| @NotNull
| @Temporal(TemporalType.TIME)
| private Date update_date = new Date();
|
| @Column(name = "intro")
| private String intro;
|
| @Column(name = "content")
| @NotNull
| private String content;
|
| @ManyToOne
| @JoinColumn(name = "photo")
| private Resource photo = new Resource();
|
| @ManyToOne
| @JoinColumn(name = "position")
| private Position position = new Position();
|
| @ManyToOne
| @JoinColumn(name = "category")
| private Category category = new Category();
|
| @ManyToMany
| @JoinTable(name = "cms_area_article", joinColumns = { @JoinColumn(name = "article") }, inverseJoinColumns = { @JoinColumn(name = "area") })
| private List<Area> areas = new ArrayList<Area>();
|
| @OneToMany(mappedBy = "article")
| private List<Comment> comments = new ArrayList<Comment>();
|
| /**
| * default constuctor
| */
| public Article() {
| super();
| }
|
| /**
| * minimal constructor
| *
| * @param id
| * @param tag
| * @param title
| * @param short_title
| * @param long_title
| * @param insert_date
| * @param update_date
| * @param content
| * @param position
| * @param category
| */
| public Article(int id, String tag, String title, String short_title,
| String long_title, Date insert_date, Date update_date,
| String content, Position position, Category category) {
| super();
| this.id = id;
| this.tag = tag;
| this.title = title;
| this.short_title = short_title;
| this.long_title = long_title;
| this.insert_date = insert_date;
| this.update_date = update_date;
| this.content = content;
| this.position = position;
| this.category = category;
| }
|
| /**
| * full constructor
| *
| * @param id
| * @param tag
| * @param title
| * @param short_title
| * @param long_title
| * @param author
| * @param click_count
| * @param insert_date
| * @param update_date
| * @param intro
| * @param content
| * @param photo
| * @param position
| * @param category
| * @param areas
| * @param comments
| */
| public Article(int id, String tag, String title, String short_title,
| String long_title, String author, int click_count,
| Date insert_date, Date update_date, String intro, String content,
| Resource photo, Position position, Category category,
| List<Area> areas, List<Comment> comments) {
| super();
| this.id = id;
| this.tag = tag;
| this.title = title;
| this.short_title = short_title;
| this.long_title = long_title;
| this.author = author;
| this.click_count = click_count;
| this.insert_date = insert_date;
| this.update_date = update_date;
| this.intro = intro;
| this.content = content;
| this.photo = photo;
| this.position = position;
| this.category = category;
| this.areas = areas;
| this.comments = comments;
| }
|
| /**
| * @return the id
| */
| public int getId() {
| return id;
| }
|
| /**
| * @param id
| * the id to set
| */
| public void setId(int id) {
| this.id = id;
| }
|
| /**
| * @return the tag
| */
| public String getTag() {
| return tag;
| }
|
| /**
| * @param tag
| * the tag to set
| */
| public void setTag(String tag) {
| this.tag = tag;
| }
|
| /**
| * @return the title
| */
| public String getTitle() {
| return title;
| }
|
| /**
| * @param title
| * the title to set
| */
| public void setTitle(String title) {
| this.title = title;
| }
|
| /**
| * @return the short_title
| */
| public String getShort_title() {
| return short_title;
| }
|
| /**
| * @param short_title
| * the short_title to set
| */
| public void setShort_title(String short_title) {
| this.short_title = short_title;
| }
|
| /**
| * @return the long_title
| */
| public String getLong_title() {
| return long_title;
| }
|
| /**
| * @param long_title
| * the long_title to set
| */
| public void setLong_title(String long_title) {
| this.long_title = long_title;
| }
|
| /**
| * @return the author
| */
| public String getAuthor() {
| return author;
| }
|
| /**
| * @param author
| * the author to set
| */
| public void setAuthor(String author) {
| this.author = author;
| }
|
| /**
| * @return the click_count
| */
| public int getClick_count() {
| return click_count;
| }
|
| /**
| * @param click_count
| * the click_count to set
| */
| public void setClick_count(int click_count) {
| this.click_count = click_count;
| }
|
| /**
| * @return the insert_date
| */
| public Date getInsert_date() {
| return insert_date;
| }
|
| /**
| * @param insert_date
| * the insert_date to set
| */
| public void setInsert_date(Date insert_date) {
| this.insert_date = insert_date;
| }
|
| /**
| * @return the update_date
| */
| public Date getUpdate_date() {
| return update_date;
| }
|
| /**
| * @param update_date
| * the update_date to set
| */
| public void setUpdate_date(Date update_date) {
| this.update_date = update_date;
| }
|
| /**
| * @return the intro
| */
| public String getIntro() {
| return intro;
| }
|
| /**
| * @param intro
| * the intro to set
| */
| public void setIntro(String intro) {
| this.intro = intro;
| }
|
| /**
| * @return the content
| */
| public String getContent() {
| return content;
| }
|
| /**
| * @return the photo
| */
| public Resource getPhoto() {
| return photo;
| }
|
| /**
| * @param photo
| * the photo to set
| */
| public void setPhoto(Resource photo) {
| this.photo = photo;
| }
|
| /**
| * @param content
| * the content to set
| */
| public void setContent(String content) {
| this.content = content;
| }
|
| /**
| * @return the position
| */
| public Position getPosition() {
| return position;
| }
|
| /**
| * @param position
| * the position to set
| */
| public void setPosition(Position position) {
| this.position = position;
| }
|
| /**
| * @return the category
| */
| public Category getCategory() {
| return category;
| }
|
| /**
| * @param category
| * the category to set
| */
| public void setCategory(Category category) {
| this.category = category;
| }
|
| /**
| * @return the areas
| */
| public List<Area> getAreas() {
| return areas;
| }
|
| /**
| * @param areas
| * the areas to set
| */
| public void setAreas(List<Area> areas) {
| this.areas = areas;
| }
|
| /**
| * @return the comments
| */
| public List<Comment> getComments() {
| return comments;
| }
|
| /**
| * @param comments
| * the comments to set
| */
| public void setComments(List<Comment> comments) {
| this.comments = comments;
| }
|
| }
|
|
here is the table definition
| CREATE TABLE `cms_article` (
| `id` int(10) unsigned NOT NULL auto_increment,
| `tag` varchar(8) NOT NULL,
| `title` varchar(32) NOT NULL,
| `short_title` varchar(32) NOT NULL,
| `long_title` varchar(32) NOT NULL,
| `author` longtext,
| `click_count` int(10) unsigned default NULL,
| `insert_date` datetime NOT NULL,
| `update_date` datetime NOT NULL,
| `intro` longtext,
| `content` longtext NOT NULL,
| `photo` int(10) unsigned default NULL,
| `position` int(10) unsigned NOT NULL,
| `category` int(10) unsigned NOT NULL,
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
here is the HQL strings
| from Article article
|
Result:
The row with null click_count won't return.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3982878#3982878
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3982878
More information about the jboss-user
mailing list