- Type Parameters:
T- entity typeU- type of the intermediate object whose attributes can be navigated to
- All Known Subinterfaces:
NavigableAttribute<T,,U> NavigablePath<T,U, V>
public interface NavigableExpression<T,U>
An expression whose type has attributes of its own
that can be navigated.
The navigate methods accept a metamodel attribute of an intermediate
type U and return a path expression rooted at the entity type
T. The type of the returned expression is determined by the type
of the attribute argument.
For example, given a Customer entity with an embeddable,
shippingAddress, of type Address,
Restrict.all(_Customer.shippingAddress.navigate(_Address.city)
.equalTo("Rochester"),
_Customer.shippingAddress.navigate(_Address.state)
.equalTo(StateCode.MN));
The following Jakarta Persistence entity and embeddable types are used in examples throughout the documentation of this class.
@Entity
public class Customer {
@Id
long id;
@Embedded
Address shippingAddress;
}
@Embeddable
public class Address {
@Embedded
BuildingInfo building;
String city;
StateCode state; // enum
LocalDate validFrom;
boolean verified;
int zip;
}
@Embeddable
public class BuildingInfo {
String buildingName;
int floor;
String officeNum;
}
The static metamodel would include,
@StaticMetamodel(Customer.class)
public interface _Customer {
String ID = "id";
String SHIPPING_ADDRESS = "shippingAddress";
NumericAttribute<Customer, Long> id =
NumericAttribute.of(Customer.class, ID, long.class);
NavigableAttribute<Customer, Address> shippingAddress =
NavigableAttribute.of(Customer.class, SHIPPING_ADDRESS, Address.class);
}
@StaticMetamodel(Address.class)
public interface _Address {
String BUILDING = "building";
String CITY = "city";
String STATE = "state";
String VALID_FROM = "validFrom";
String VERIFIED = "verified";
String ZIP = "zip";
NavigableAttribute<Address, BuildingInfo> building =
NavigableAttribute.of(Address.class, BUILDING, BuildingInfo.class);
TextAttribute<Address> city =
TextAttribute.of(Address.class, CITY);
ComparableAttribute<Address, StateCode> state =
ComparableAttribute.of(Address.class, STATE, StateCode.class);
TemporalAttribute<Address, LocalDate> validFrom =
TemporalAttribute.of(Address.class, VALID_FROM, LocalDate.class);
BooleanAttribute<Address> verified =
BooleanAttribute.of(Address.class, VERIFIED, boolean.class);
NumericAttribute<Address, Integer> zip =
NumericAttribute.of(Address.class, ZIP, int.class);
}
@StaticMetamodel(BuildingInfo.class)
public interface _BuildingInfo {
String BUILDING_NAME = "buildingName";
String FLOOR = "floor";
String OFFICE_NUM = "officeNum";
TextAttribute<BuildingInfo> buildingName =
TextAttribute.of(BuildingInfo.class, BUILDING_NAME);
NumericAttribute<BuildingInfo, Integer> floor =
NumericAttribute.of(BuildingInfo.class, FLOOR, int.class);
TextAttribute<BuildingInfo> officeNum =
TextAttribute.of(BuildingInfo.class, OFFICE_NUM);
}
- Since:
- 1.1
-
Method Summary
Modifier and TypeMethodDescriptiondefault BooleanExpression<T> navigate(BooleanAttribute<U> attribute) Represents navigation to aBooleanAttribute.default <C extends Comparable<C>>
ComparableExpression<T, C> navigate(ComparableAttribute<U, C> attribute) Represents navigation to aComparableAttribute.default <V> NavigableExpression<T, V> navigate(NavigableAttribute<U, V> attribute) Allows navigation to an attribute that can be further navigated.default <N extends Number & Comparable<N>>
NumericExpression<T, N> navigate(NumericAttribute<U, N> attribute) Represents navigation to aNumericAttribute.default <V extends Temporal & Comparable<? extends Temporal>>
TemporalExpression<T, V> navigate(TemporalAttribute<U, V> attribute) Represents navigation to aTemporalAttribute.default TextExpression<T> navigate(TextAttribute<U> attribute) Represents navigation to aTextAttribute.
-
Method Details