Hi I am new with spring and hibernate
I download an application form internet and need to run it
https://github.com/philipsorst/angular- ... ngsecurityI had the following Entities
Code:
package net.dontdrinkandroot.example.angularrestspringsecurity.entity;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
@javax.persistence.Entity
public class User implements Entity, UserDetails
{
@Id
@GeneratedValue
private Long id;
@Column(unique = true, length = 16, nullable = false)
private String name;
@Column(length = 80, nullable = false)
private String password;
@ElementCollection(fetch = FetchType.EAGER)
private Set<Role> roles = new HashSet<Role>();
protected User()
{
/* Reflection instantiation */
}
public User(String name, String passwordHash)
{
this.name = name;
this.password = passwordHash;
}
public Long getId()
{
return this.id;
}
public void setId(Long id)
{
this.id = id;
}
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name = name;
}
public Set<Role> getRoles()
{
return this.roles;
}
public void setRoles(Set<Role> roles)
{
this.roles = roles;
}
public void addRole(Role role)
{
this.roles.add(role);
}
@Override
public String getPassword()
{
return this.password;
}
public void setPassword(String password)
{
this.password = password;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities()
{
return this.getRoles();
}
@Override
public String getUsername()
{
return this.name;
}
@Override
public boolean isAccountNonExpired()
{
return true;
}
@Override
public boolean isAccountNonLocked()
{
return true;
}
@Override
public boolean isCredentialsNonExpired()
{
return true;
}
@Override
public boolean isEnabled()
{
return true;
}
}
Code:
package net.dontdrinkandroot.example.angularrestspringsecurity.entity;
import org.springframework.security.core.GrantedAuthority;
public enum Role implements GrantedAuthority
{
USER("ROLE_USER"),
ADMIN("ROLE_ADMIN");
private String authority;
Role(String authority)
{
this.authority = authority;
}
@Override
public String getAuthority()
{
return this.authority;
}
}
but I don't know how to create the tables
if any body can help me with this please