Configured the project to use Hibernate validation

This requires the Hibernate Tools (a part of JBoss Tools) to be
installed in Eclipse.
This commit is contained in:
Kai S. K. Engelbart 2020-04-09 14:15:39 +02:00
parent e285b6d75e
commit 53764f1bba
5 changed files with 23 additions and 18 deletions

View File

@ -25,10 +25,16 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.hibernate.eclipse.console.hibernateBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.hibernate.eclipse.console.hibernateNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View File

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<faceted-project> <faceted-project>
<installed facet="jpt.jpa" version="2.1"/>
<installed facet="java" version="11"/> <installed facet="java" version="11"/>
<installed facet="jpt.jpa" version="2.1"/>
</faceted-project> </faceted-project>

View File

@ -24,7 +24,7 @@ import envoy.data.User;
@Entity @Entity
@Table(name = "groups") @Table(name = "groups")
@NamedQuery(query = "SELECT g FROM Group g WHERE g.name = :name", name = "getGroupByName") @NamedQuery(query = "SELECT g FROM Group g WHERE g.name = :name", name = "getGroupByName")
public final class Group extends Contact { public class Group extends Contact {
/** /**
* {@inheritDoc} * {@inheritDoc}

View File

@ -5,11 +5,12 @@ import java.util.stream.Collectors;
import javax.persistence.*; import javax.persistence.*;
import envoy.data.User.UserStatus;
/** /**
* This class serves as a way to let Hibernate communicate with the server * This class enables the storage of user specific data inside a database using
* without bringing the dependency of JPA/Hibernate into the client.<br> * Hibernate. Its objects will be referred to as database users as opposed to
* It will be referenced as "database user" to clarify between the different * the common user objects present on both the client and the server.<br>
* user objects.<br>
* <br> * <br>
* Project: <strong>envoy-server-standalone</strong><br> * Project: <strong>envoy-server-standalone</strong><br>
* File: <strong>User.java</strong><br> * File: <strong>User.java</strong><br>
@ -30,13 +31,14 @@ import javax.persistence.*;
name = "searchUsers" name = "searchUsers"
) } ) }
) )
public final class User extends Contact { public class User extends Contact {
private byte[] passwordHash; private byte[] passwordHash;
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date lastSeen; private Date lastSeen;
private envoy.data.User.UserStatus status;
private UserStatus status;
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -47,7 +49,7 @@ public final class User extends Contact {
} }
/** /**
* @return the passwordHash of a {link envoy.data.User} * @return the password hash
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
*/ */
public byte[] getPasswordHash() { return passwordHash; } public byte[] getPasswordHash() { return passwordHash; }
@ -55,33 +57,30 @@ public final class User extends Contact {
/** /**
* @param passwordHash the password hash to set * @param passwordHash the password hash to set
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
* @see User#getPasswordHash()
*/ */
public void setPasswordHash(byte[] passwordHash) { this.passwordHash = passwordHash; } public void setPasswordHash(byte[] passwordHash) { this.passwordHash = passwordHash; }
/** /**
* @return the last date an {link envoy.data.User} has been online * @return the last date the user has been online
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
*/ */
public Date getLastSeen() { return lastSeen; } public Date getLastSeen() { return lastSeen; }
/** /**
* @param lastSeen the latest date at which has been seen to set * @param lastSeen the latest date at which the user has been online to set
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
* @see User#getLastSeen()
*/ */
public void setLastSeen(Date lastSeen) { this.lastSeen = lastSeen; } public void setLastSeen(Date lastSeen) { this.lastSeen = lastSeen; }
/** /**
* @return the status of a {link envoy.data.User} * @return the status
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
*/ */
public envoy.data.User.UserStatus getStatus() { return status; } public UserStatus getStatus() { return status; }
/** /**
* @param status the status to set * @param status the status to set
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
* @see User#getStatus()
*/ */
public void setStatus(envoy.data.User.UserStatus status) { this.status = status; } public void setStatus(UserStatus status) { this.status = status; }
} }