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
dungdm93 / ER diagram.png
Last active Dec 28, 2015
[Java] [JPA] Map @OneToMany, @manytoone example
We couldn’t find that file to show.
@dungdm93
dungdm93 / Parameters.java
Created Aug 28, 2015
[Java] [JPA] [JPQL] Parameters example
View Parameters.java
// 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
dungdm93 / EclipseLink.out
Last active Aug 31, 2015
[Java][JPA] Field vs. Property Access
View EclipseLink.out
@dungdm93
dungdm93 / User.java
Last active Aug 30, 2015
[Java][JPA] LOB example
View User.java
import javax.persistence.*;
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
@Lob
private String avatar;
@dungdm93
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
Employee.prePersist
[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()
Employee.postPersist
========================================
[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]
Employee.postLoad
@dungdm93
dungdm93 / Company.java
Created Aug 31, 2015
[Java][JPA] xml vs. annotation models mapping
View Company.java
package com.gem.demo.database.model;
public class Company {
public int id;
public String name;
public String address;
...
@Override
@dungdm93
dungdm93 / ConstructorReferenceDemo.java
Created Sep 1, 2015
[Java 8] Constructor Reference example
View ConstructorReferenceDemo.java
interface NoArgConstructor<T> {
T foo();
}
interface ArgConstructor<T, U> {
T bar(U arg);
}
interface MultiArgsConstructor<T, U> {
T magic(U... arg);
@dungdm93
dungdm93 / Model.java
Created Nov 5, 2015
[Java][JPA][Hibernate] UUID & Hibernate
View Model.java
@Entity
public class Employee extends AbstractBaseEntity {
// Approach 1:
// @Id
// public String id;
// Approach 2:
@Id
// default column type is byte array
@Type(type = "org.hibernate.type.PostgresUUIDType") // or type = "pg-uuid"
You can’t perform that action at this time.