Skip to content

Instantly share code, notes, and snippets.

View javaeeeee's full-sized avatar

Dmitry Noranovich javaeeeee

View GitHub Profile
@javaeeeee
javaeeeee / Employee.java
Created November 6, 2015 13:02
An Employee entity
@Entity
@Table(name = "employees")
@NamedQueries({
@NamedQuery(name = "com.javaeeeee.dwstart.core.Employee.findAll",
query = "select e from Employee e"),
@NamedQuery(name = "com.javaeeeee.dwstart.core.Employee.findByName",
query = "select e from Employee e "
+ "where e.firstName like :name "
+ "or e.lastName like :name")
})
@javaeeeee
javaeeeee / employee.sql
Created November 6, 2015 13:00
A script to create employee table
-- A script to create employee table
create table employees(
-- auto-generated primary key
id bigint primary key not null auto_increment,
first_name varchar(255) not null,
last_name varchar(255) not null,
-- employee position
e_position varchar(255) not null,
phone varchar(255) not null,
e_mail varchar(255) not null
@javaeeeee
javaeeeee / DWGettingStartedConfiguration.java
Created November 6, 2015 12:58
Changes to Configuration class to enable database connection in a Dropwizard project
public class DWGettingStartedConfiguration extends Configuration {
...
/**
* A factory used to connect to a relational database management system.
* Factories are used by Dropwizard to group together related configuration
* parameters such as database connection driver, URI, password etc.
*/
@NotNull
@javaeeeee
javaeeeee / pom.xml
Last active November 10, 2015 11:23
Hibernate and Database driver dependencies for a Dropwizard project
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-hibernate</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.36</version>
</dependency>
@javaeeeee
javaeeeee / config.yml
Created November 6, 2015 12:51
Database configuration for a Dropwizard project
# Database settings.
database:
# the name of the JDBC driver, mysql in our case
driverClass: com.mysql.jdbc.Driver
# the username
user: javaeeeee
# the password
password: 1
# the JDBC URL; the database is called DWGettingStarted
url: jdbc:mysql://localhost:3306/DWGettingStarted
@javaeeeee
javaeeeee / test-config.yml
Created October 29, 2015 09:57
Dropwizard configuration file for testing
## YAML Template.
---
password: p@ssw0rd
#Server configuration.
server:
applicationConnectors:
- type: http
port: 8080
- type: https
@javaeeeee
javaeeeee / HAL representation with embedded objects
Created February 28, 2015 11:42
HAL representation with embedded objects
{
"_links":{
"self":{
"href":"/author/4554"
},
"curries":[
{
"name":"ns",
"href":"http://booklistapi.com/rels/{rel}",
"templated":true
@javaeeeee
javaeeeee / HAL representation with CURIE
Last active August 29, 2015 14:16
HAL representation with CURIE
{
"_links":{
"self":{
"href":"/book/123"
},
"curries":[
{
"name":"ns",
"href":"http://booklistapi.com/rels/{rel}",
"templated":true
@javaeeeee
javaeeeee / HAL representation with custom relation type
Last active August 29, 2015 14:16
HAL representation with custom relation type
{
"_links":{
"self":{
"href":"/book/123"
},
"http://booklistapi.com/rels/authors":[
{
"href":"/author/4554",
"title":"Leonard Richardson"
},
@javaeeeee
javaeeeee / HAL representation with self link
Created February 28, 2015 11:40
HAL representation with self link