This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NamedQueries(@NamedQuery(name = "Trip.findByVehicle", query = "SELECT trip FROM Trip trip WHERE vehicle=:vehicle")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// define EJB client properties | |
final Properties props = new Properties(); | |
// define SSL encryption | |
props.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", | |
"true"); | |
props.put("remote.connection.default.connect.options.org.xnio.Options.SSL_STARTTLS", | |
"true"); | |
// connection properties | |
props.put("remote.connections", "default"); | |
props.put("remote.connection.default.host", "localhost"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
@Table(name = "purchaseOrder") | |
@NamedEntityGraph(name = "graph.Order.items", | |
attributeNodes = @NamedAttributeNode(value = "items", subgraph = "items"), | |
subgraphs = @NamedSubgraph(name = "items", attributeNodes = @NamedAttributeNode("product"))) | |
public class Order implements Serializable { | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
@Column(name = "id", updatable = false, nullable = false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Converter | |
public class CryptoConverter implements AttributeConverter<String, String> { | |
private static final String ALGORITHM = "AES/ECB/PKCS5Padding"; | |
private static final byte[] KEY = "MySuperSecretKey".getBytes(); | |
@Override | |
public String convertToDatabaseColumn(String ccNumber) { | |
// do some encryption | |
Key key = new SecretKeySpec(KEY, "AES"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
@Remote(SingletonRemote.class) | |
public class DefaultLock implements SingletonRemote { | |
Logger logger = Logger.getLogger(DefaultLock.class.getName()); | |
private int counter = 0; | |
@Override | |
public void method1() { | |
this.logger.info("method1: " + counter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<BookValue> results = ((Session)this.em.getDelegate()).createSQLQuery("SELECT b.id, b.title, b.version, a.firstName || ' ' || a.lastName as authorName FROM Book b JOIN Author a ON b.author_id = a.id") | |
.addScalar("id", StandardBasicTypes.LONG).addScalar("title").addScalar("version", StandardBasicTypes.LONG).addScalar("authorName") | |
.setResultTransformer(new AliasToBeanResultTransformer(BookValue.class)).list(); | |
results.stream().forEach((book) -> { | |
System.out.println("Book: ID [" + book.getId() + "] title [" + book.getTitle() + "] authorName [" + book.getAuthorName() + "]"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set input parameter | |
query.setParameter("x", 1.23d); | |
query.setParameter("y", 4.56d); | |
// call the stored procedure and get the result | |
query.execute(); | |
Double sum = (Double) query.getOutputParameterValue("sum"); |
OlderNewer