/* * Copyright 2011, Nabil Benothman, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package com.ubike.model; import java.io.Serializable; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; import org.hibernate.annotations.Index; /** * {@code Authority} * <p/> * * Created on Jun 6, 2011 at 7:17:22 PM * * @author <a href="mailto:nabil.benothman@gmail.com">Nabil Benothman</a> */ @Entity @Table(name = "AUTHORITIES") @NamedQueries({ @NamedQuery(name = "Authority.getAll", query = "SELECT o FROM Authority o"), @NamedQuery(name = "Authority.getByUserName", query = "SELECT o FROM Authority o WHERE o.username=:param"), @NamedQuery(name = "Authority.getByAccount", query = "SELECT o FROM Authority o WHERE o.account.id=:param") }) public class Authority implements Serializable { public static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional=false) @Column(name = "ID") private Long id; @Index(name = "username_index") @Column(name = "USERNAME", nullable = false) private String username; @Column(name = "AUTHORITY", nullable = false) private String authority; @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "ID_ACCOUNT", referencedColumnName = "ID") private Account account; /** * Creates a new instance of {@code Authority} */ public Authority() { super(); } /** * Creates a new instance of {@code Authority} * * @param username * @param authority */ public Authority(Account account, String username, String authority) { this.account = account; this.username = username; this.authority = authority; } /** * @return the id */ public Long getId() { return id; } /** * @param id the id to set */ public void setId(Long id) { this.id = id; } /** * @return the username */ public String getUsername() { return username; } /** * @param username the username to set */ public void setUsername(String username) { this.username = username; } /** * @return the authority */ public String getAuthority() { return authority; } /** * @param authority the authority to set */ public void setAuthority(String authority) { this.authority = authority; } /** * @return the account */ public Account getAccount() { return account; } /** * @param account the account to set */ public void setAccount(Account account) { this.account = account; } }