/src/classes/com/sapienter/jbilling/server/invoice/db/InvoiceDeliveryMethodDTO.java

https://github.com/othmanelmoulat/jbilling-2.2-Extentions · Java · 117 lines · 81 code · 17 blank · 19 comment · 0 complexity · 7967dc7bacaba19843d8858d26356cab MD5 · raw file

  1. /*
  2. jBilling - The Enterprise Open Source Billing System
  3. Copyright (C) 2003-2009 Enterprise jBilling Software Ltd. and Emiliano Conde
  4. This file is part of jbilling.
  5. jbilling is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU Affero General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. jbilling is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Affero General Public License for more details.
  13. You should have received a copy of the GNU Affero General Public License
  14. along with jbilling. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. package com.sapienter.jbilling.server.invoice.db;
  17. import java.io.Serializable;
  18. import java.util.HashSet;
  19. import java.util.Set;
  20. import javax.persistence.CascadeType;
  21. import javax.persistence.Column;
  22. import javax.persistence.Entity;
  23. import javax.persistence.FetchType;
  24. import javax.persistence.GeneratedValue;
  25. import javax.persistence.GenerationType;
  26. import javax.persistence.Id;
  27. import javax.persistence.JoinColumn;
  28. import javax.persistence.JoinTable;
  29. import javax.persistence.ManyToMany;
  30. import javax.persistence.OneToMany;
  31. import javax.persistence.Table;
  32. import javax.persistence.TableGenerator;
  33. import javax.persistence.Version;
  34. import com.sapienter.jbilling.server.user.db.CompanyDTO;
  35. import com.sapienter.jbilling.server.user.db.CustomerDTO;
  36. import org.hibernate.annotations.Cache;
  37. import org.hibernate.annotations.CacheConcurrencyStrategy;
  38. @Entity
  39. @TableGenerator(
  40. name = "invoice_delivery_method_GEN",
  41. table = "jbilling_seqs",
  42. pkColumnName = "name",
  43. valueColumnName = "next_id",
  44. pkColumnValue = "invoice_delivery_method",
  45. allocationSize = 100)
  46. @Table(name = "invoice_delivery_method")
  47. @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
  48. public class InvoiceDeliveryMethodDTO implements Serializable {
  49. private int id;
  50. private Set<CompanyDTO> entities = new HashSet<CompanyDTO>(0);
  51. private Set<CustomerDTO> customers = new HashSet<CustomerDTO>(0);
  52. private int versionNum;
  53. public InvoiceDeliveryMethodDTO() {
  54. }
  55. public InvoiceDeliveryMethodDTO(int id) {
  56. this.id = id;
  57. }
  58. public InvoiceDeliveryMethodDTO(int id, Set<CompanyDTO> entities,
  59. Set<CustomerDTO> customers) {
  60. this.id = id;
  61. this.entities = entities;
  62. this.customers = customers;
  63. }
  64. @Id
  65. @GeneratedValue(strategy = GenerationType.TABLE, generator = "invoice_delivery_method_GEN")
  66. @Column(name = "id", unique = true, nullable = false)
  67. public int getId() {
  68. return this.id;
  69. }
  70. public void setId(int id) {
  71. this.id = id;
  72. }
  73. @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  74. @JoinTable(name = "entity_delivery_method_map", joinColumns = { @JoinColumn(name = "method_id", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "entity_id", updatable = false) })
  75. public Set<CompanyDTO> getEntities() {
  76. return this.entities;
  77. }
  78. public void setEntities(Set<CompanyDTO> entities) {
  79. this.entities = entities;
  80. }
  81. @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "invoiceDeliveryMethod")
  82. public Set<CustomerDTO> getCustomers() {
  83. return this.customers;
  84. }
  85. public void setCustomers(Set<CustomerDTO> customers) {
  86. this.customers = customers;
  87. }
  88. @Version
  89. @Column(name="OPTLOCK")
  90. public int getVersionNum() {
  91. return versionNum;
  92. }
  93. public void setVersionNum(int versionNum) {
  94. this.versionNum = versionNum;
  95. }
  96. }