Skip to content

Instantly share code, notes, and snippets.

@kevinhooke
kevinhooke / gist:61392cc16a4d8270bfa0
Created July 2, 2015 18:19
mysql grant all privileges to user
grant all privileges on test.* to test identified by 'test';
@kevinhooke
kevinhooke / gist:85d5b2d5864fd9835cc4
Created July 2, 2015 20:54
Standalone persistence.xml against MySQL
<?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 July 2, 2015 20:57
Initialize standalone PersistenceManager for standalone app
EntityManagerFactory emf = Persistence.createEntityManagerFactory("TestPU");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(exampleEntity);
em.getTransaction().commit();
@kevinhooke
kevinhooke / gist:89f2e10c13dce8a32ed4
Created July 2, 2015 20:58
JPA create a copy of existing entity using detach()
ExampleA a = new ExampleA();
em.getTransaction().begin();
em.persist(a);
em.getTransaction().commit();
// ...
em.getTransaction().begin();
em.detach(a);
@kevinhooke
kevinhooke / gist:90351b04b0ea9a34c3e3
Created July 2, 2015 21:00
JPA 2.0 with HIbernate 3.5.6 pom.xml
<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 January 4, 2016 22:56
Maven skip tests / skip failures
#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 July 14, 2015 17:57
tcpdump for all tcp on if eth0
tcpdump -i eth0 tcp
@kevinhooke
kevinhooke / gist:f5e2f30f1ed12fea1229
Last active August 29, 2015 14:24
centos 7 useful network commands
#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 August 29, 2015 14:27
Spring Transaction api - check tx status
//check is active
TransactionSynchronizationManager.isActualTransactionActive();
//get status
TransactionStatus status = TransactionAspectSupport.currentTransactionStatus();
<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>