Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[MultiKeys]: Support multiple keys and added JavaDoc
  • Loading branch information
FroMage committed Nov 8, 2010
1 parent 59eedaa commit 18342d1
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions framework/src/play/db/Model.java
Expand Up @@ -3,6 +3,8 @@
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;

import play.Play;
import play.PlayPlugin;
import play.exceptions.UnexpectedException;
Expand All @@ -22,6 +24,7 @@ public static class Property {
public boolean isMultiple;
public boolean isRelation;
public boolean isGenerated;
public boolean isKey;
public Class<?> relationType;
public Choices choices;

Expand All @@ -35,15 +38,41 @@ public static interface Choices {

public static interface Factory {

/**
* Returns the list of properties for this factory's type.
*/
public List<Model.Property> listProperties();
/**
* Returns the list of key properties for this factory's type.
*/
public List<Model.Property> listKeys();
/**
* @deprecated this only works for single non-composite keys. It will throw an exception in every other case. Use listKeys().
*/
@Deprecated
public String keyName();
/**
* Returns the type of key. For a single key it will be the key's field's type. For a composite key this will be the type
* of the composite key (as specified by @IdClass)
*/
public Class<?> keyType();
/**
* Returns the key value. For a single key it will return the key's field. For a composite key this will return an instance of the type
* of the composite key (as specified by @IdClass)
*/
public Object keyValue(Model m);
/**
* Makes a key valid for this factory's type, with all the given components of this key taken from a map.
*/
public Object makeKey(Map<String, Object> id);
public Model findById(Object id);
/**
* Returns true if this factory's type has a generated key, false if the user can set the key himself.
*/
public boolean isGeneratedKey();
public List<Model> fetch(int offset, int length, String orderBy, String orderDirection, List<String> properties, String keywords, String where);
public Long count(List<String> properties, String keywords, String where);
public void deleteAll();
public List<Model.Property> listProperties();

}

public static class Manager {
Expand Down

0 comments on commit 18342d1

Please sign in to comment.