1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.messageboards.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.impl.BaseModelImpl;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.portlet.messageboards.model.MBDiscussion;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  /**
39   * <a href="MBDiscussionModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>MBDiscussion</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portlet.messageboards.service.model.MBDiscussion
54   * @see com.liferay.portlet.messageboards.service.model.MBDiscussionModel
55   * @see com.liferay.portlet.messageboards.service.model.impl.MBDiscussionImpl
56   *
57   */
58  public class MBDiscussionModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "MBDiscussion";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "discussionId", new Integer(Types.BIGINT) },
62              
63  
64              { "classNameId", new Integer(Types.BIGINT) },
65              
66  
67              { "classPK", new Integer(Types.BIGINT) },
68              
69  
70              { "threadId", new Integer(Types.BIGINT) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table MBDiscussion (discussionId LONG not null primary key,classNameId LONG,classPK LONG,threadId LONG)";
73      public static final String TABLE_SQL_DROP = "drop table MBDiscussion";
74      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
75                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBDiscussion"),
76              true);
77      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
78                  "lock.expiration.time.com.liferay.portlet.messageboards.model.MBDiscussion"));
79  
80      public MBDiscussionModelImpl() {
81      }
82  
83      public long getPrimaryKey() {
84          return _discussionId;
85      }
86  
87      public void setPrimaryKey(long pk) {
88          setDiscussionId(pk);
89      }
90  
91      public Serializable getPrimaryKeyObj() {
92          return new Long(_discussionId);
93      }
94  
95      public long getDiscussionId() {
96          return _discussionId;
97      }
98  
99      public void setDiscussionId(long discussionId) {
100         if (discussionId != _discussionId) {
101             _discussionId = discussionId;
102         }
103     }
104 
105     public long getClassNameId() {
106         return _classNameId;
107     }
108 
109     public void setClassNameId(long classNameId) {
110         if (classNameId != _classNameId) {
111             _classNameId = classNameId;
112         }
113     }
114 
115     public long getClassPK() {
116         return _classPK;
117     }
118 
119     public void setClassPK(long classPK) {
120         if (classPK != _classPK) {
121             _classPK = classPK;
122         }
123     }
124 
125     public long getThreadId() {
126         return _threadId;
127     }
128 
129     public void setThreadId(long threadId) {
130         if (threadId != _threadId) {
131             _threadId = threadId;
132         }
133     }
134 
135     public MBDiscussion toEscapedModel() {
136         if (isEscapedModel()) {
137             return (MBDiscussion)this;
138         }
139         else {
140             MBDiscussion model = new MBDiscussionImpl();
141 
142             model.setEscapedModel(true);
143 
144             model.setDiscussionId(getDiscussionId());
145             model.setClassNameId(getClassNameId());
146             model.setClassPK(getClassPK());
147             model.setThreadId(getThreadId());
148 
149             model = (MBDiscussion)Proxy.newProxyInstance(MBDiscussion.class.getClassLoader(),
150                     new Class[] { MBDiscussion.class },
151                     new ReadOnlyBeanHandler(model));
152 
153             return model;
154         }
155     }
156 
157     public Object clone() {
158         MBDiscussionImpl clone = new MBDiscussionImpl();
159 
160         clone.setDiscussionId(getDiscussionId());
161         clone.setClassNameId(getClassNameId());
162         clone.setClassPK(getClassPK());
163         clone.setThreadId(getThreadId());
164 
165         return clone;
166     }
167 
168     public int compareTo(Object obj) {
169         if (obj == null) {
170             return -1;
171         }
172 
173         MBDiscussionImpl mbDiscussion = (MBDiscussionImpl)obj;
174 
175         long pk = mbDiscussion.getPrimaryKey();
176 
177         if (getPrimaryKey() < pk) {
178             return -1;
179         }
180         else if (getPrimaryKey() > pk) {
181             return 1;
182         }
183         else {
184             return 0;
185         }
186     }
187 
188     public boolean equals(Object obj) {
189         if (obj == null) {
190             return false;
191         }
192 
193         MBDiscussionImpl mbDiscussion = null;
194 
195         try {
196             mbDiscussion = (MBDiscussionImpl)obj;
197         }
198         catch (ClassCastException cce) {
199             return false;
200         }
201 
202         long pk = mbDiscussion.getPrimaryKey();
203 
204         if (getPrimaryKey() == pk) {
205             return true;
206         }
207         else {
208             return false;
209         }
210     }
211 
212     public int hashCode() {
213         return (int)getPrimaryKey();
214     }
215 
216     private long _discussionId;
217     private long _classNameId;
218     private long _classPK;
219     private long _threadId;
220 }