ðSupported Features
Spring OData Supported features
Basic Search
Sort
Sort by property
Group by more than one property
Property
Validation
Pagination
Entity type
Collection Type
OData data types
Collection Type Enum Type Complex Type Navigation Property Reference Navigation Property
CRUD
Nesting CRUD
Keys
Primary Keys
Single Primary Key: A unique identifier that consists of a single column in a table. This column ensures that each row in the table is uniquely identified by its values.
Composite Primary Key: A primary key that consists of two or more columns in a table. The combination of values across these columns must be unique to ensure the uniqueness of each row.
Inheritance
Entity Type Inheritance
Entity Type: In the context of entity types, inheritance refers to the ability of a subtype (child entity) to inherit attributes and relationships from a supertype (parent entity).
Complex Type Inheritance
Complex Type: Inheritance allows you to create a hierarchy of complex types, where a subtype can inherit the properties of a parent complex type.
Query Capabilities
Here {{host}}
is the IP Address and Port number of the deployed Application and {{servletname}}
is the Service Name of the application.
Basic Search
$filter: Supports filtering records based on conditions.
Example: To filter PetCareCenters whose name contains "John":
Select Specific Fields
$select: Allows you to GET only the required fields.
Example: To get only the names and emails of PetCareCenters:
Sorting
$orderby: Supports sorting by a specific property.
Example: To sort PetCareCenters by
Name
in ascending order:Example: To sort PetCareCenters by
Name
in descending order:
Grouping
$apply: Supports grouping by one or more properties using the
groupby
transformation.Example: To group PetCareCenters by
Name
:Example: To group PetCareCenters by
Name
andBranchName
:
Pagination
$top: Retrieves only the top N records.
Example: To get the top 2 PetCareCenters:
$skip: Skips the first N records.
Example: To skip the first PetCareCenters:
Expand Related Entities
$expand: Retrieves related entities.
Example: To get PetCareCenters with their PetService:
Count Entities
$count: Retrieves the number of entities.
Example: To get the number of PetCareCenters:
Single Column Value
$value: Retrieves the raw value of a single property.
Example: To get the PetCareCenters Name as a raw value:
Data Model
Entity Type
An entity type represents a specific type of entity in the data model. It corresponds to a table in an underlying database and defines the structure of the data, including properties and relationships.
Collection Type
Code Wizard supports CRUD operations on collection navigation properties. This represents a one-to-many or many-to-many relationship between collections of associated objects. It allows you to navigate from one entity to a collection of related entities.
Let's consider this Pet Care model which includes several entities such as PetCareCenter
, Pet
, PetService
, etc. This model encompasses various attributes and associations, providing a comprehensive structure for managing pet care services. Below are the detailed descriptions of the entities and their relationships:
Entities and Attributes
PetCareCenter
Attributes:
pcId
(Int): Unique identifier for the pet care center.name
(String): Name of the pet care center.location
(String): Location of the pet care center.businessHours
(List(String)): List of business hours.isOperational
(Boolean): Indicates whether the center is currently operational.
Associations:
One-to-One with
Manager
: EachPetCareCenter
can be associated with oneManager
. Here the association name isSupervisor
.One-to-One with
Document
: EachPetCareCenter
can be associated with oneDocument
. Here the association name isLogo
.One-to-Many with
Document
: EachPetCareCenter
can be associated with multipleDocument
. Here the association name isImages
.One-to-Many with
Services
: EachPetCareCenter
can be associated with multiplePetServices
. Here the association name isServices
.One-to-Many with
Pet
: EachPetCareCenter
can be associated with multiplePet
. Here the association name isPets
.
Manager
Attributes:
mId
(Int): Unique identifier for the manager.fullName
(String): Full name of the manager.contactNumber
(String): Contact number of the manager.address
(String): Address of the manager.
Associations:
One-to-One with
PetCareCenter
: EachManager
is associated with onePetCareCenter
.
PetService
Attributes:
serviceId
(Int): Unique identifier for the pet service.durationInHours
(Int): Duration in hour of the pet service.serviceType
(PetServiceType): Type of the pet service (using an enum for predefined types).price
(Double): Price of the service.
Associations:
One-to-Many with
PetCareCenter
: EachPetCareCenter
can offer multiplePetServices
.
Pet
Attributes:
petId
(Int): Unique identifier for the pet.petName
(String): Name of the pet.color
(String): Color of the pet.breed
(String): Breed of the pet.height
(Decimal): Height of the pet.
PetOwner
Attributes:
ownerId
(Int): Unique identifier for the pet owner.ownerName
(String): Name of the pet owner.contactPrimary
(String): Primary contact number of the pet owner.address
(String): Address of the pet owner.
Associations:
One-to-Many with
Pet
: EachPetOwner
can have multiplePet
s.
Document
Attributes:
docId
(Int): Unique identifier for the document.docName
(String): Name of the document.fileType
(String): File name of the document.
Enum Type
PetServiceType is an Enum Type which has the types of pet services offered.
Possible Values:
PetGrooming = 1
PetBoarding = 2
PetTraining = 3
PetSitting = 4
PetTherapy = 5
Enum Type
Spring OData template supports Enum, or enumeration, is a data type that consists of a set of named constants. Enums provide a way to define a group of related constant values in a more expressive and readable way.
Complex Type
Code-Wizard template use/support complex type is a type that does not have a key and cannot exist independently. It is typically used as a component of another entity type or complex type. Complex types are often used to represent a group of associated object properties that can be treated as a single unit.
Since complex types do not have a standalone identity, their manipulation is directly tied to the operations performed on the parent entity.
Navigation Property
Navigation properties are used to define relationships between different entity types. These navigation properties allow you to navigate from one entity to related entities, making it easier to work with data of associated objects.
Reference Navigation Property
A reference navigation property represents a one-to-one or many-to-one relationship between entities. It allows you to navigate from one entity to a related entity. For example, if you have a relationship between a "Customer" entity and an "Order" entity, the reference navigation property might allow you to access the customer associated with a particular order.
Nesting CRUD
Nesting a "Create" operation typically means creating a new record or data entry within the context of a related parent record.
Template supports Spring Data JPA (Spring Data framework) for the ORM capabilities. It simplifies the implementation of JPA (Java Persistence API) based repositories. It provides a way to use JPA to store data in a relational database and can be seen as an abstraction layer over the JPA, making it easier to work with databases using JPA
Example:
This will create one pet care center and two pets ans associate them.
Operations or queries Code-Wizard support
Code-Wizard supports various operations on the entities defined in the model. Here are the details of the Create, Read, Update, and Delete (CRUD) operations using the PetCareCenter
entity as an example.
1. Create Operation
To create a new PetCareCenter
, you would use an HTTP POST request.
Example:
2. Read Operation
To read or retrieve data about a PetCareCenter
, you would use an HTTP GET request.
Example:
Get all PetCareCenters:
Get a specific PetCareCenter by ID:
3. Update Operation
To update an existing PetCareCenter
, you would use an HTTP PATCH request.
Example:
4. Delete Operation
To delete an existing PetCareCenter
, you would use an HTTP DELETE request.
Example:
Working with Enums
In your Pet Care model, you can use enums to represent predefined sets of values. This is particularly useful for properties like ServiceType
in the PetService
entity. Here's how you can work with enums. You can post petsevice with service type that is a enum property, you need to mention enum value of the respective enum options there like for PetGrooming
it is 1.
Example:
Sorting and Filtering Based on Enum Type
You can also sort and filter your data based on the enum property. For instance, to filter PetServices
by ServiceType
, you would use the enum value in your query.
Example:
Filter by
ServiceType
:
Working with complex types
This model does not contain complex types but we support them, you can perform all the operations there.
Example:
Filter by
HomeAddress/Address
:
Last updated