Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have worked on projects which use static String like the following - as you suggested:</p> <pre><code>public static final String DESCRIPTION = "description"; </code></pre> <p>These were however only used to access domain model properties in the Data access tier rather than in the presentation tier. Personally I find it rather ugly.</p> <p>To ensure consistency between Domain and Data Access tier you could have a look at using the Criteria API and the JPA Metamodel which allows for robust type-safe querying: as your domain model changes, the metamodel should also update automatically to reflect these changes.</p> <p><a href="https://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html/metamodel.html" rel="nofollow">https://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html/metamodel.html</a></p> <p>It is not something I have really used as I find QueryDSL and its simlar strongly typed Metamodel based queries much simpler to use. So this would be an alternative to the JPA Criteria API that might be worth looking at. For example if I have the following where QBooking is a MetaModel 'Query Object' auto-generated by QueryDSL any changes to the domain model (e.g. forename renamed to firstname) are automatically reflected in the Query Object:</p> <pre><code>QBooking.booking qb = QBooking.booking ; bookingRepository.findAll(qb.accommodation.holiday.eq(holiday).and( qb.status.eq(BookingStatus.CONFIRMED)), qb.skillLevel.level.asc(), qb.user.surname.asc(), qb.user.forename.asc()) </code></pre> <p>None of this ensures consistency between the presentation tier and your domain model of course, however I find that in reality the renaming of fields (if you have given the naming of them in the first place a modicum of thought) tends to occur fairly infrequently.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload