Skip to content

Instantly share code, notes, and snippets.

Working hard

Đặng Minh Dũng dungdm93

Working hard
Block or report user

Report or block dungdm93

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dungdm93 /
Created Aug 28, 2015
[Java] [JPA] [JPQL] Parameters example
// JPA defines named parameters, and positional parameters.
// Named parameters can be specified in JPQL using the syntax :<name>.
Query query = em.createQuery("SELECT e FROM Employee e WHERE e.firstName = :first and e.lastName = :last");
query.setParameter("first", "Bob");
query.setParameter("last", "Smith");
List<Employee> list = query.getResultList();
// Positional parameters can be specified in JPQL using the syntax ? or ?<position>.
// Positional parameters start at position 1 not 0.
dungdm93 /
Last active Aug 30, 2015
[Java][JPA] LOB example
import javax.persistence.*;
public class User {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
private String avatar;
dungdm93 / Console.txt
Last active Aug 30, 2015
[Java][JPA] Listener & Callback example
View Console.txt
[EL Info]: connection: 2015-08-30 12:52:11.554--ServerSession(1286783232)--/file:/C:/Users/KiT/IdeaProjects/Database Sample/service/target/classes/_pu login successful
[EL Fine]: sql: 2015-08-30 12:52:11.635--ClientSession(1437983537)--Connection(1614079837)--INSERT INTO EMPLOYEE (NAME, SALARY) VALUES (?, ?)
bind => [2 parameters bound]
[EL Fine]: sql: 2015-08-30 12:52:11.637--ClientSession(1437983537)--Connection(1614079837)--SELECT LAST_INSERT_ID()
[EL Fine]: sql: 2015-08-30 12:52:11.729--ServerSession(1286783232)--Connection(1614079837)--SELECT ID, NAME, SALARY FROM EMPLOYEE WHERE (ID = ?)
bind => [1 parameter bound]
dungdm93 / EclipseLink.out
Last active Aug 31, 2015
[Java][JPA] Field vs. Property Access
View EclipseLink.out
dungdm93 /
Created Aug 31, 2015
[Java][JPA] xml vs. annotation models mapping
package com.gem.demo.database.model;
public class Company {
public int id;
public String name;
public String address;
dungdm93 /
Created Sep 1, 2015
[Java 8] Constructor Reference example
interface NoArgConstructor<T> {
T foo();
interface ArgConstructor<T, U> {
T bar(U arg);
interface MultiArgsConstructor<T, U> {
T magic(U... arg);
dungdm93 /
Created Nov 5, 2015
[Java][JPA][Hibernate] UUID & Hibernate
public class Employee extends AbstractBaseEntity {
// Approach 1:
// @Id
// public String id;
// Approach 2:
// default column type is byte array
@Type(type = "org.hibernate.type.PostgresUUIDType") // or type = "pg-uuid"
import java.util.NoSuchElementException;
import java.util.Random;
public class RandomString {
public static void main(String[] args) {
long time = System.currentTimeMillis();
dungdm93 / ER diagram.png
Last active Dec 28, 2015
[Java] [JPA] Map @OneToMany, @manytoone example
You can’t perform that action at this time.