- Timestamp:
- Feb 26, 2007, 12:22:00 PM (16 years ago)
- Location:
- branches/2.2.2/src/core/net/sf/basedb/core/query
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.2/src/core/net/sf/basedb/core/query/Hql.java
r2497 r3152 27 27 import net.sf.basedb.core.InvalidDataException; 28 28 import net.sf.basedb.core.InvalidUseOfNullException; 29 import net.sf.basedb.core.data.BasicData; 29 30 30 31 import java.util.regex.Pattern; … … 55 56 56 57 /** 57 Create an expression representing an item . In the query the actual58 value used is the id of the entity. See {@link #property(String, String)}59 for a code example.58 Create an expression representing an item which is a subclass of BasicItem. 59 In the query the actual value used is the id of the entity. 60 See {@link #property(String, String)} for a code example. 60 61 61 62 @param entity The entity 62 @throws InvalidDataException If the etity is null 63 @throws InvalidDataException If the entity is null 64 @see #entity(BasicData) 63 65 */ 64 66 public static Expression entity(BasicItem entity) … … 69 71 } 70 72 73 /** 74 Create an expression representing an item which is a subclass of BasicData, 75 for example a reporter. In the query the actual value used is the id of the entity. 76 See {@link #property(String, String)} for a code example. 77 78 @param entity The entity 79 @throws InvalidDataException If the entity is null 80 @see #entity(BasicItem) 81 @since 2.2.2 82 */ 83 public static Expression entity(BasicData entity) 84 throws InvalidDataException 85 { 86 if (entity == null) throw new InvalidUseOfNullException("entity"); 87 return new HqlEntityExpression(entity); 88 } 89 71 90 /** 72 91 Same as <code>property(null, property)</code>. -
branches/2.2.2/src/core/net/sf/basedb/core/query/HqlEntityExpression.java
r2667 r3152 29 29 import net.sf.basedb.core.BasicItem; 30 30 import net.sf.basedb.core.BaseException; 31 import net.sf.basedb.core.data.BasicData; 31 32 32 33 /** … … 39 40 @version 2.0 40 41 @see Hql#entity(BasicItem) 42 @see Hql#entity(BasicData) 41 43 @base.modified $Date$ 42 44 */ … … 44 46 implements Expression 45 47 { 46 private final BasicItem item; 48 private final int id; 49 private final String item; 47 50 48 51 HqlEntityExpression(BasicItem item) 49 52 { 50 this.item = item; 53 this.id = item.getId(); 54 this.item = item.toString(); 55 } 56 57 /** 58 @since 2.2.2 59 */ 60 HqlEntityExpression(BasicData data) 61 { 62 this.id = data.getId(); 63 this.item = data.toString(); 51 64 } 52 65 … … 60 73 if (query.getQueryType() == QueryType.HQL) 61 74 { 62 return Integer.toString(i tem.getId());75 return Integer.toString(id); 63 76 } 64 77 else … … 81 94 public String toString() 82 95 { 83 return item .toString();96 return item; 84 97 } 85 98 // -------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.