package org.dionysus.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.Valid;

import org.hibernate.validator.constraints.NotBlank;

@Entity
@Table(name = "articles")
public class Article extends AbstractDionysusAuditable<User> {

	private static final long serialVersionUID = 4106093798545531113L;

	@NotBlank
	@Column(name = "title")
	private String title;

	@NotBlank
	@Lob @Column(name = "body")
	private String body;

	@Valid
	@ManyToOne(cascade = CascadeType.PERSIST)
	private Category category;

	@Version
	private Long version;

	public Article() {
		this.version = 0L;
	}

	public Article(String title, String body) {
		this.title = title;
		this.body = body;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}
	
	@Override
	public String toString() {
		return this.title;
	}
}

@@ -588,17 +588,18 @@
 nk%0A%09@Lob
- 
+%0A%09
 @Column(
@@ -726,16 +726,101 @@
 Version%0A
+%09@Column(name = %22version%22, columnDefinition = %22integer DEFAULT 0%22, nullable = false)%0A
 %09private
@@ -859,29 +859,8 @@
 ) %7B%0A
-%09%09this.version = 0L;%0A
 %09%7D%0A%0A
@@ -1421,17 +1421,16 @@
 ion;%0A%09%7D%0A
-%09
 %0A%09@Overr

add default value for version