Skip to content

Instantly share code, notes, and snippets.

@kevinhooke
kevinhooke / gist:61392cc16a4d8270bfa0
Created Jul 2, 2015
mysql grant all privileges to user
View gist:61392cc16a4d8270bfa0
grant all privileges on test.* to test identified by 'test';
@kevinhooke
kevinhooke / gist:85d5b2d5864fd9835cc4
Created Jul 2, 2015
Standalone persistence.xml against MySQL
View gist:85d5b2d5864fd9835cc4
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="TestPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>list entities here if running as standalone app</class>
<properties>
@kevinhooke
kevinhooke / gist:5e577a882b13ca8ed121
Created Jul 2, 2015
Initialize standalone PersistenceManager for standalone app
View gist:5e577a882b13ca8ed121
EntityManagerFactory emf = Persistence.createEntityManagerFactory("TestPU");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(exampleEntity);
em.getTransaction().commit();
@kevinhooke
kevinhooke / gist:89f2e10c13dce8a32ed4
Created Jul 2, 2015
JPA create a copy of existing entity using detach()
View gist:89f2e10c13dce8a32ed4
ExampleA a = new ExampleA();
em.getTransaction().begin();
em.persist(a);
em.getTransaction().commit();
// ...
em.getTransaction().begin();
em.detach(a);
@kevinhooke
kevinhooke / gist:90351b04b0ea9a34c3e3
Created Jul 2, 2015
JPA 2.0 with HIbernate 3.5.6 pom.xml
View gist:90351b04b0ea9a34c3e3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kh.jpa</groupId>
<artifactId>example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
@kevinhooke
kevinhooke / gist:1943714bd3a1a474cceb
Last active Jan 4, 2016
Maven skip tests / skip failures
View gist:1943714bd3a1a474cceb
#skip all tests
-Dmaven.test.skip
#if runing tests, skip failures (don't fail build on test fail)
-Dmaven.test.failure.ignore=true
@kevinhooke
kevinhooke / gist:3dc73d6db589fd47f829
Created Jul 14, 2015
tcpdump for all tcp on if eth0
@kevinhooke
kevinhooke / gist:f5e2f30f1ed12fea1229
Last active Aug 29, 2015
centos 7 useful network commands
View gist:f5e2f30f1ed12fea1229
#restart network
sudo /etc/init.d/network restart
#firewalld stop|start
sudo systemctl firewalld.service stop|start|status
firewall-config
- add port for 7001 for WebLogic access (zone=public, port, add 7001/tcp)
@kevinhooke
kevinhooke / gist:bc3c029d4db80a26d28e
Last active Aug 29, 2015
Spring Transaction api - check tx status
View gist:bc3c029d4db80a26d28e
//check is active
TransactionSynchronizationManager.isActualTransactionActive();
//get status
TransactionStatus status = TransactionAspectSupport.currentTransactionStatus();
View Log4J 1.x Hibernate logging
<logger name="org.hibernate.SQL"> <!-- in persistence.xml can also do property name="hibernate.show_sql" value="true" -->
<level value="debug"/>
</logger>
<logger name="org.hibernate.type">
<level value="trace"/>
</logger>