Skip to content

Instantly share code, notes, and snippets.

View rafaeltuelho's full-sized avatar
🎯
Focusing

Rafael T. C. Soares (A.K.A Tuelho) rafaeltuelho

🎯
Focusing
  • Red Hat Inc.
  • Frisco, TX, USA
  • 02:15 (UTC -05:00)
View GitHub Profile
@rafaeltuelho
rafaeltuelho / OBIEEHttpServletBridge.java
Last active August 29, 2015 13:57
Java HTTP Servlet to be used as a bridge between a Web APP and Oracle BI Server when using OBIEE SOAP API for integration scenarios.
package br.net.rafaeltuelho.servlets;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
@rafaeltuelho
rafaeltuelho / arquillian.xml
Last active August 29, 2015 14:07
Arquillian Descritor example for JBoss/Wildfly Integration tests
<?xml version="1.0" encoding="UTF-8"?>
<!--
JBoss, Home of Professional Open Source
Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
contributors by the @authors tag. See the copyright.txt in the
distribution for a full listing of individual contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@rafaeltuelho
rafaeltuelho / jboss-as-javaee-6-arquillian-pom.xml
Last active August 29, 2015 14:07
Maven POM example for JBoss EAP/Wildfly JavaEE 6 projects. Includes JBoss EAP and Arquillian BOMs (Maven JBoss/JavaEE 6 standard definitions)
<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>br.net.rafaeltuelho</groupId>
<artifactId>unit1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<description>JB297 Training</description>
<developers>
<developer>
@rafaeltuelho
rafaeltuelho / jboss-persistence-jta.xml
Last active August 29, 2015 14:07
JPA (2.1) Persistence Unit sample for use in JBoss EAP/Wildfly environments
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="unit1" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
@rafaeltuelho
rafaeltuelho / ShrinkWrap-ArquillianTest-Snippet.java
Last active August 29, 2015 14:08
Shrinkwrap code snippet to generate an Arquillian deployment archive to test inside a JBossAS/EAP
@Deployment
public static Archive<?> createDeployment() {
// You can use war packaging...
@SuppressWarnings("unused")
WebArchive war = ShrinkWrap
.create(WebArchive.class, "test.war")
.addPackage(Bus.class.getPackage())
// .addAsManifestResource(
// new File("src/main/resources/META-INF",
// "persistence.xml"))
@rafaeltuelho
rafaeltuelho / persistence-hibernate-properties.xml
Last active November 21, 2022 05:54
Some Hibernate properties to use in your JPA persistence.xml descriptor
<!-- Hibenate JPA Provider -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.use_sql_coments" value="true" />
<property name="hibernate.generate_statistics" value="true" />
<!-- Infinispan -->
@rafaeltuelho
rafaeltuelho / jpa-qry-api-examples.java
Created November 2, 2014 21:44
Some JPA Query API code snippet samples
public void findindAllUsingJpqlQuery() throws Exception {
// given
String fetchingAllInJpql = "select e from " + ENTITY_NAME
+ " e order by e.id";
// when
System.out.println("Selecting (using JPQL)...");
List<Entity> entities = em.createQuery(fetchingAllInJpql,
Entity.class).getResultList();
@rafaeltuelho
rafaeltuelho / persistence-unit-jpa-2.0-resource-local.xml
Last active October 23, 2015 14:10
Persistence unit JPA 2.0 witn resource local (non-jta-datasource) sample XML
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="unit3" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- non-jta-datasource>jdbc/arquillian</non-jta-datasource -->
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
@rafaeltuelho
rafaeltuelho / EntityManager-sample.java
Created November 7, 2014 17:41
Creating an JPA EntityManager
// in JavaSE environment
EntityManagerFactory emf = Persistence.createEntityManagerFactory("sample");
EntityManager em = emf.createEntityManager();
try{
...
]
finally{
em.close();
@rafaeltuelho
rafaeltuelho / java-eclipse-projects.gitignore
Created November 7, 2014 19:50
.gitignore sample file for java eclipse maven projects
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear