Skip to content

Conversation

@damini1994
Copy link
Contributor

No description provided.

@rohitnandi12 rohitnandi12 changed the title #8 Adds AuditingEntityListener #8 Adds Event Endpoint, Auditing entity Oct 30, 2024
private Event event;

@OneToMany(mappedBy = "show", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<SeatInShow> seatInShows;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Builder.Default
private List seatInShows = new ArrayList<>();

@Repository
public interface EventRepository extends JpaRepository<Event, UUID> {

@Query("SELECT e FROM Event e JOIN FETCH e.vendor JOIN FETCH e.venue JOIN FETCH e.eventType")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not required. Bydefault JPA will use Joins. We can test it by running the code and checking hibernate logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it seems there is an issue with the entity mapping, resulting in an entity not found exception


public static final String STATUS_200 = "200";
public static final String MESSAGE_200 = "Request processed successfully";
public static final String EVENT_SUCCESS_MESSAGE = "Events fetched successfully";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use interface for constants , I am not sure creating constant in class

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nareshthecoder No, interface can be inherited and usually Interface in Java is used to define API not constants.

@Override
public ApiListResponse<Event> getAllEvents(int page, int size) {
try {
Page<Event> eventsPage = eventRepository.findAllWithDetails(PageRequest.of(page, size));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need default sorting for fetching data ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DTO is not required?

@NotNull
private Instant startDate;

@NotNull
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NotNull will enforce a not null check from the application side, but it will not create a NOT NULL constraint on the database end. Bothe has to be added.

What is missing here is the Request, Response, and DTO layers.
@NotNull and similar spring validation should be in Request layer

Entity should have @column(nullable = false)

public interface IEventRepository extends JpaRepository<Event, UUID> {

@Query("SELECT e FROM Event e JOIN FETCH e.vendor JOIN FETCH e.venue JOIN FETCH e.eventType")
@Query("SELECT e FROM Event e JOIN FETCH e.vendor JOIN FETCH e.venue JOIN FETCH e.eventType ORDER BY e.startDate DESC")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This query is still not required. Just passing the pageable will do the job. @manytoone annotation are FetchType.Eager by default hence JPA will use joins to fetch data.

@rohitnandi12 rohitnandi12 merged commit 01e77b4 into rohitnandi12:feature/8-user-portal-part-1 Nov 9, 2024
rohitnandi12 added a commit that referenced this pull request Nov 14, 2024
* #8 Adds init spring-boot project

* #8 Adds Instant type jackson converter

* #8 Adds ApiErrorResponse

* #8 Adds ApiResponse

* #8 Adds ApiListResponse

* #8 Adds TestBaseAuditingEntity

* Feature/8 user portal part 1 (#17)

* #8 Adds init spring-boot project

* #8 Adds Instant type jackson converter

* #8 Adds ApiErrorResponse

* #8 Adds ApiResponse

* #8 Adds ApiListResponse

* #8 Adds TestBaseAuditingEntity

* #8 Adds Event Endpoint, Auditing entity (#18)

* #8 Adds AuditingEntityListener

* #8 Adds BookingStatus, Genre, OperationalStatus, VendorStatus, VenueType enums

* #8 Add entities Event, EventShow, EventType, Seat, SeatInShow, SeatType, SeatTypeInShow, Vendor, Venue

* #8 Add getAllEvents endpoints

* #8 Add test cases for getAllEvents endpoints

* Resolved reviewed comments

* Resolved reviewed comments

* #8 Resolved reviewed comments

* Refactor code to events package

* Adds response layer, fix test cases. Removes sonar lints

---------

Co-authored-by: damini1994 <55175815+damini1994@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants