001 /****************************************************************
002 * Licensed to the Apache Software Foundation (ASF) under one *
003 * or more contributor license agreements. See the NOTICE file *
004 * distributed with this work for additional information *
005 * regarding copyright ownership. The ASF licenses this file *
006 * to you under the Apache License, Version 2.0 (the *
007 * "License"); you may not use this file except in compliance *
008 * with the License. You may obtain a copy of the License at *
009 * *
010 * http://www.apache.org/licenses/LICENSE-2.0 *
011 * *
012 * Unless required by applicable law or agreed to in writing, *
013 * software distributed under the License is distributed on an *
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015 * KIND, either express or implied. See the License for the *
016 * specific language governing permissions and limitations *
017 * under the License. *
018 ****************************************************************/
019 package org.apache.james.domainlist.jpa.model;
020
021 import javax.persistence.Column;
022 import javax.persistence.Entity;
023 import javax.persistence.Id;
024 import javax.persistence.NamedQueries;
025 import javax.persistence.NamedQuery;
026 import javax.persistence.Table;
027
028 /**
029 * Domain class for the James Domain to be used for JPA persistence.
030 */
031 @Entity(name = "JamesDomain")
032 @Table(name = "JAMES_DOMAIN")
033 @NamedQueries({
034 @NamedQuery(name = "findDomainByName", query = "SELECT domain FROM JamesDomain domain WHERE domain.name=:name"),
035 @NamedQuery(name = "containsDomain", query = "SELECT COUNT(domain) FROM JamesDomain domain WHERE domain.name=:name"),
036 @NamedQuery(name = "listDomainNames", query = "SELECT domain.name FROM JamesDomain domain"),
037 @NamedQuery(name = "deleteDomainByName", query = "DELETE FROM JamesDomain domain WHERE domain.name=:name") })
038 public class JPADomain {
039
040 /**
041 * The name of the domain. column name is chosen to be compatible with the
042 * JDBCDomainList.
043 */
044 @Id
045 @Column(name = "DOMAIN_NAME", nullable = false, length = 100)
046 private String name;
047
048 /**
049 * Default no-args constructor to avoid warning during JPA class enhancement.
050 * Do not us this.
051 */
052 @SuppressWarnings(value = "unused" )
053 private JPADomain() {
054 }
055
056 /**
057 * Use this simple constructor to create a new Domain.
058 *
059 * @param name
060 * the name of the Domain
061 */
062 public JPADomain(String name) {
063 this.name = name;
064 }
065
066 }