Class CollectionFieldResolver
java.lang.Object
io.github.blyznytsiaorg.bibernate.entity.type.CollectionFieldResolver
- All Implemented Interfaces:
TypeFieldResolver
Implementation of
TypeFieldResolver
for resolving custom injection values for collection fields of an entity class.
This resolver is responsible for determining if a given field of an entity class represents a collection relationship and preparing the value to be injected into the field.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
isAppropriate
(Field field) Determines if the resolver is appropriate for the given field.prepareValueForFieldInjection
(Field field, ResultSet resultSet, Object entity, EntityPersistent entityPersistent) Prepares the value to be injected into the specified field of the entity.
-
Constructor Details
-
CollectionFieldResolver
public CollectionFieldResolver()
-
-
Method Details
-
isAppropriate
Determines if the resolver is appropriate for the given field. This implementation returns
true
if the field represents a collection relationship.- Specified by:
isAppropriate
in interfaceTypeFieldResolver
- Parameters:
field
- the field to be evaluated for custom injection- Returns:
true
if the field represents a collection relationship,false
otherwise
-
prepareValueForFieldInjection
public Object prepareValueForFieldInjection(Field field, ResultSet resultSet, Object entity, EntityPersistent entityPersistent) Prepares the value to be injected into the specified field of the entity. This implementation retrieves the associated entities from the database based on the collection relationship type.
- Specified by:
prepareValueForFieldInjection
in interfaceTypeFieldResolver
- Parameters:
field
- the field to receive the injected valueresultSet
- the result set containing the data from which the value will be extractedentity
- the entity object to which the field belongsentityPersistent
- the persistent metadata associated with the entity- Returns:
- the value to be injected into the field, typically a collection of associated entities
- Throws:
BibernateGeneralException
- if an error occurs while retrieving the associated entities
-