Created
April 4, 2011 11:18
-
-
Save Eugeny/901484 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fksis.domain.entities; | |
import java.io.Serializable; | |
import javax.persistence.*; | |
import java.util.Date; | |
import java.util.Set; | |
/** | |
* The persistent class for the MESSAGE database table. | |
* | |
*/ | |
@Entity | |
@Table(name = "MESSAGE", schema = "MAIN") | |
public class Message implements Serializable { | |
private static final long serialVersionUID = 1L; | |
private long id; | |
private boolean isDeleted; | |
private Date sentTime; | |
private String text; | |
private User author; | |
private Set<MessageToUser> recipients; | |
public Message() { | |
} | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
@Column(name = "ID", unique = true, nullable = false) | |
public long getId() { | |
return this.id; | |
} | |
public void setId(long id) { | |
this.id = id; | |
} | |
@Column(name = "IS_DELETED") | |
public boolean getIsDeleted() { | |
return this.isDeleted; | |
} | |
public void setIsDeleted(boolean isDeleted) { | |
this.isDeleted = isDeleted; | |
} | |
@Temporal(TemporalType.DATE) | |
@Column(name = "SENT_TIME") | |
public Date getSentTime() { | |
return this.sentTime; | |
} | |
public void setSentTime(Date sentTime) { | |
this.sentTime = sentTime; | |
} | |
public String getText() { | |
return this.text; | |
} | |
public void setText(String text) { | |
this.text = text; | |
} | |
@ManyToOne | |
@JoinColumn(name = "AUTHOR_ID") | |
public User getAuthor() { | |
return this.author; | |
} | |
public void setAuthor(User author) { | |
this.author = author; | |
} | |
@OneToMany(mappedBy = "message", fetch = FetchType.EAGER) | |
public Set<MessageToUser> getRecipients() { | |
return this.recipients; | |
} | |
public void setRecipients(Set<MessageToUser> recipients) { | |
this.recipients = recipients; | |
} | |
@Override | |
public String toString() { | |
StringBuilder builder = new StringBuilder(); | |
builder.append("Message [id="); | |
builder.append(id); | |
builder.append(", text="); | |
builder.append(text); | |
builder.append(", sentTime="); | |
builder.append(sentTime); | |
builder.append(", deleted="); | |
builder.append(isDeleted); | |
builder.append(", author="); | |
builder.append(author.getLogin()); | |
builder.append("]"); | |
return builder.toString(); | |
} | |
} | |
package fksis.dal.jpa; | |
import org.springframework.stereotype.Repository; | |
import fksis.dal.interfaces.MessageDao; | |
import fksis.domain.entities.Message; | |
@Repository | |
public class MessageDaoImpl extends JpaDao<Message, Long> implements MessageDao { | |
} | |
CREATE TABLE "MAIN "."MESSAGE" ( | |
"TEXT" VARCHAR(2000) , | |
"IS_DELETED" SMALLINT , | |
"SENT_TIME" DATE , | |
"ID" BIGINT NOT NULL , | |
"AUTHOR_ID" BIGINT NOT NULL ) | |
IN "USERSPACE1" ; | |
-- DDL Statements for indexes on Table "MAIN "."MESSAGE" | |
CREATE INDEX "MAIN "."XIF1MESSAGE" ON "MAIN "."MESSAGE" | |
("AUTHOR_ID" ASC) | |
ALLOW REVERSE SCANS; | |
-- DDL Statements for indexes on Table "MAIN "."MESSAGE" | |
CREATE UNIQUE INDEX "MAIN "."XPKMESSAGE" ON "MAIN "."MESSAGE" | |
("ID" ASC) | |
ALLOW REVERSE SCANS; | |
-- DDL Statements for primary key on Table "MAIN "."MESSAGE" | |
ALTER TABLE "MAIN "."MESSAGE" | |
ADD CONSTRAINT "XPKMESSAGE" PRIMARY KEY | |
("ID"); | |
-- DDL Statements for foreign keys on Table "MAIN "."MESSAGE" | |
ALTER TABLE "MAIN "."MESSAGE" | |
ADD CONSTRAINT "R_72" FOREIGN KEY | |
("AUTHOR_ID") | |
REFERENCES "MAIN "."USER" | |
("ID") | |
ON DELETE NO ACTION | |
ON UPDATE NO ACTION | |
ENFORCED | |
ENABLE QUERY OPTIMIZATION; | |
-- DDL Statements for check constraints on Table "MAIN "."MESSAGE" | |
ALTER TABLE "MAIN "."MESSAGE" | |
ADD CONSTRAINT "BOOLEAN__435092686" CHECK | |
(IS_DELETED BETWEEN 0 AND 1) | |
ENFORCED | |
ENABLE QUERY OPTIMIZATION; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment