Buggy code:
public class RSPersistenceJPA implements RSPersistence { private static final Logger log = LoggerFactory . getLogger ( RSPersistence . class ) ; private final Provider < EntityManager > em ; private final SecureIdGenerator secureIdGenerator = new SecureIdGenerator ( ) ; private final TimeZone localTimeZone ; private final Object listenersLock = new Object ( ) ; private ImmutableSet < RSPersistenceListener > listeners = ImmutableSet . of ( ) ; @ Inject public RSPersistenceJPA ( final Provider < EntityManager > em , final TimeZone timeZone ) { } @ Override @ Transactional public ConfidentialReservationData addReservation ( final List < NodeUrn > nodeUrns , final DateTime from , final DateTime to , final String username , final NodeUrnPrefix urnPrefix , final String description , final List < KeyValuePair > options ) throws RSFault_Exception { } @ Override @ Transactional public ConfidentialReservationData getReservation ( SecretReservationKey srk ) throws RSFault_Exception , UnknownSecretReservationKeyFault { } @ Override @ Transactional public ConfidentialReservationData cancelReservation ( SecretReservationKey srk ) throws RSFault_Exception , UnknownSecretReservationKeyFault { } @ Override @ Transactional public ConfidentialReservationData finalizeReservation ( SecretReservationKey secretReservationKey ) throws RSFault_Exception , UnknownSecretReservationKeyFault { } @ Override public void addListener ( final RSPersistenceListener rsPersistenceListener ) { } @ Override public void removeListener ( final RSPersistenceListener listener ) { } @ Override @ Transactional @ SuppressWarnings ( { "unchecked" , "ConstantConditions" } ) public List < ConfidentialReservationData > getReservations ( @ Nullable final DateTime from , @ Nullable final DateTime to , @ Nullable final Integer offset , @ Nullable final Integer amount , @ Nullable Boolean showCancelled ) throws RSFault_Exception { } @ Override public List < ConfidentialReservationData > getNonFinalizedReservations ( ) throws RSFault_Exception { } @ Override public List < ConfidentialReservationData > getActiveReservations ( ) throws RSFault_Exception { } @ Override public List < ConfidentialReservationData > getFutureReservations ( ) throws RSFault_Exception { } @ Override public List < ConfidentialReservationData > getActiveAndFutureReservations ( ) throws RSFault_Exception { } @ Override public Optional < ConfidentialReservationData > getReservation ( final NodeUrn nodeUrn , final DateTime timestamp ) throws RSFault_Exception { @ SuppressWarnings ( "unchecked" ) <START_BUG> final List < ReservationDataInternal > resultList = ( ( List < ReservationDataInternal > ) ( em . get ( ) . createNamedQuery ( QUERY_NAME ) . setParameter ( P_TIMESTAMP , timestamp . getMillis ( ) ) . setParameter ( P_NODE_URN , nodeUrn ) . getResultList ( ) ) ) ; <END_BUG> if ( resultList . isEmpty ( ) ) { return Optional . absent ( ) ; } if ( ( resultList . size ( ) ) > 1 ) { throw new RSFault_Exception ( ( ( ( "Found<seq2seq4repair_space>more<seq2seq4repair_space>than<seq2seq4repair_space>one<seq2seq4repair_space>reservation<seq2seq4repair_space>for<seq2seq4repair_space>node<seq2seq4repair_space>URN<seq2seq4repair_space>" + nodeUrn ) + "<seq2seq4repair_space>at<seq2seq4repair_space>timestamp<seq2seq4repair_space>" ) + timestamp ) , new RSFault ( ) ) ; } try { return Optional . of ( TypeConverter . convertConfidentialReservationData ( resultList , localTimeZone ) . get ( 0 ) ) ; } catch ( DatatypeConfigurationException e ) { throw new RSFault_Exception ( e . getMessage ( ) , new RSFault ( ) ) ; } } }

Fix:
final List < ReservationDataInternal > resultList = ( ( List < ReservationDataInternal > ) ( em . get ( ) . createNamedQuery ( QUERY_NAME ) . setParameter ( P_TIMESTAMP , timestamp . getMillis ( ) ) . setParameter ( P_NODE_URN , nodeUrn . toString ( ) ) . getResultList ( ) ) ) ;