Thursday, April 21, 2016

Tell Git to Ignore File Changes

git update-index --assume-unchanged doc.asciidoc
git ls-files -v | grep '^[hsmrck?]' | cut -c 3-
git update-index --no-assume-unchanged doc.asciidoc

Clean Working Directory with Git

git reset --hard
git clean -xdf

Note: reset all files to their last-committed state and remove all uncommitted files

Tuesday, April 12, 2016

Monday, April 11, 2016

TIL: Oracle BPEL Process Manager

BPEL is the standard for assembling a set of discrete services into an end-to-end process flow, radically reducing the cost and complexity of process integration initiatives. Oracle BPEL Process Manager offers a comprehensive and easy-to-use infrastructure for creating, deploying and managing BPEL business processes. 

 http://www.oracle.com/technetwork/middleware/bpel/overview/index.html

Thursday, March 31, 2016

Push to GitHub from Visual Studio Code

git config --global credential.helper wincred
git push

Monday, March 28, 2016

Windows wireless service is not running on this computer in Windows 10

Run the following commands in the command prompt as Administrator to fix the issue in Windows 10. A system restart will be required.

netsh winsock reset catalog
netsh int ip reset reset.log hit

Sunday, March 27, 2016

BindingResult result follows validated object

BindingResult result has to follow the object show that it binds to properly validate the inputs. Otherwise, you'll get an exception similar to "field error in object on field rejected value codes".

@RequestMapping(value={"/addnewshow", "/editshow"}, method=RequestMethod.POST)
public String processShow(@Valid @ModelAttribute("show") Show show, BindingResult result,
@RequestParam(value="showid", required=false) Long showId)
{
if(result.hasErrors()){
return "myapp.editshow";
}
else{
show.setId(showId);
show = showService.save(show);
}
return "redirect:editshow.html?showid=" + show.getId();
}

Thursday, March 24, 2016

Installing ODP.NET_Managed_ODAC12cR4

ODP.NET_Managed_ODAC12cR4>install_odpm.bat c:\oracle12c_client_64 x86 true


Wednesday, March 16, 2016

Querystring or Model values

<c:set var="showId" value="${param.showid}"/>
~
<c:set var="showId" value="${show.getId()}"/>

Monday, March 14, 2016

Java Config dataSourceInitializer

@Value("classpath:db/sql/insert-data.sql")
private org.springframework.core.io.Resource DATA_SCRIPT;

@Bean
public DataSourceInitializer dataSourceInitializer(final DataSource dataSource) {

   final DataSourceInitializer initializer = new DataSourceInitializer();
   initializer.setDataSource(dataSource);
   initializer.setDatabasePopulator(databasePopulator());  
   return initializer;
}

private DatabasePopulator databasePopulator() {
   final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
   populator.addScript(DATA_SCRIPT);
   return populator;
}

OR

populator.addScript(new ClassPathResource("db/sql/insert-data.sql"));

Sunday, March 13, 2016

H2 Database



C:\DEV\Apps\h2-2016-01-21\h2\bin>h2w.bat

Saturday, February 27, 2016

JAVA JPA Goal Repository

JAVA JPA
//Repository
package com.thekhuc.repository;

import java.util.List;

import com.thekhuc.model.Goal;
import com.thekhuc.model.GoalReport;

public interface GoalRepository {

Goal save(Goal goal);

List<Goal> loadAll();

List<GoalReport> findAllGoalReports();

}

//Interface
package com.thekhuc.repository;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

import org.springframework.stereotype.Repository;

import com.thekhuc.model.Goal;
import com.thekhuc.model.GoalReport;

@Repository("goalRepository")
public class GoalRepositoryImpl implements GoalRepository {

@PersistenceContext
private EntityManager em;

@Override
public Goal save(Goal goal) {
if(goal.getId() == null){
em.persist(goal);
em.flush();
}
else{
goal = em.merge(goal);
}
return goal;
}

@Override
public List<Goal> loadAll() {
//Query query=em.createQuery("Select g from Goal g");

TypedQuery<Goal> query = em.createNamedQuery(Goal.FIND_ALL_GOALS, Goal.class);
return query.getResultList();
}

@Override
public List<GoalReport> findAllGoalReports() {
//Query query = em.createQuery("Select new com.thekhuc.model.GoalReport(g.minutes, e.minutes, e.activity) " +
// "from Goal g, Exercise e where g.id = e.goal.id");

TypedQuery<GoalReport> query = em.createNamedQuery(Goal.FIND_GOAL_REPORTS, GoalReport.class);
return query.getResultList();
}

}

Sunday, February 21, 2016

persistence.xml

/src/main/resources/META-INF/persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.or/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/XML/ns/persistence http://java.sun.com/xml/ns/persistence_2_0.xsd"
version="2.0">

<persistence-unit name="punit"></persistence-unit>

</persistence>

jpaContext.xml

/src/main/resources/jpaContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">

<context:annotation-config/>

<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="punit"/>
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true"/>
</bean>
</property>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<entry key="hibernate.hbm2ddl.auto" value="create"/>
<entry key="hibernate.format_sql" value="true"/>
</map>
</property>
</bean>

<bean id="transactionmanager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>

<tx:annotation-driven transaction-manager="transactionManager"/>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/fitnesstracker?autoReconnect=true"/>
<property name="username" value=""/>
<property name="password" value=""/>
</bean>

</beans>

Installing MySQL Community Server 5.7.11 and Python 3.5.1




Friday, February 19, 2016

Sunday, November 15, 2015

Consuming a RESTful Web Service Video and Notes

mkdir src/main/java/hello

@JsonIgnoreProperties - any properties not bound in this type should be ignored.

gradle bootRun
or
gradle build
java -jar build/libs/gs-consuming-rest-0.1.0.jar

OR

gradle wrapper
./gradlew bootRun
or
./gradlew build
java -jar build/libs/gs-consuming-rest-0.1.0.jar

OR

mvn spring-boot:run
or
mvn clean package
java -jar target/gs-consuming-rest-0.1.0.jar

output:
2015-11-14 03:20:26.415  INFO 23613 --- [main] hello.Application  : Quote{type='success', value=Value{id=12, quote='@springboot with @springframework is pure productivity! Who said in #java one has to write double the code than in other langs? #newFavLib'}}