Tuesday, December 31, 2013

Farewell Spring.NET

In Spring Framework .Net website:
ANNOUNCEMENT: Dear Spring Community, We are pleased to announce that the M2 (Milestone 2) release of Spring .NET 2.0.0 is now available. Download | Community This is a preview release designed to enable early-adopters to evaluate and comment on features and contains the following new features:
  • Autowiring attribute for field DI
Several fixed to the core container are also included in this release In addition to the direct download, this M2 release has been made available as NuGet 'pre-release' packages (see Spring.Core on NuGet as an example). Please provide feedback/input on this pre-release via the Spring.NET Forums.
[2012-12-11]
No progress from 2012-12-11, Pivotal seems dumped .NET and concentrate on Java only... good bye Spring .NET, you are a great framework that I'm enjoying to work with, a magic helper in my .NET projects...
On other hand, with the concentration on Java frameworks, we can hope the increase of productivity (and release?) from Pivotal (or SpringSource). Is this a good news for "Java Developers"?

Friday, December 27, 2013

Coursera's Functional Programming Principles in Scala

So incidentally I found this course, since it's free, I thought: hi why not I register for it, so I can get better understanding of Scala? And, the I'm registered


Dear Desson Ariawan,
Thank you for signing up for Functional Programming Principles in Scala! Software is at the core of most of our products and services now, so programming is a pervasive activity. At the same time, we know that productivity of programmers can differ by more than one order of magnitude, much more than in most other disciplines.  
The course is self-contained. People have found it useful to discuss with others in the forums and/or by forming study groups. As a  new offering, Typesafe is also proposing commercial online tutorial sessions where small groups of students interact with an expert to discuss their programming techniques in a more individual way (but they won't tell you how to do your homework :-). If that interests you, here's a blog explaining more details
I hope that you will find this class useful for improving your programming skills by letting you concentrate on the essentials of abstraction and composition. 
Yours,
Martin

Check https://www.coursera.org/course/progfun for details

Update: Unfortunately, I still has no time to go through this course :(

Wednesday, December 25, 2013

Just For Fun - Hello World in Scala

Prologue
I just assume that you already have Scala installed in your Windows computer. Once you have installed it, you can open a command prompt window (simply by press "windows"+R (Run), then type "cmd" enter OK). In the command prompt window, you can enter a simple command to open Scala interactive shell:


If you get the above result (note: the version number may be different), then everything is fine. But you can also have the misfortune to get an error message, that the command is not recognized. If that happen, please remember to setup user environment correctly. As example in my case:


Hello World in Console
 object HelloWorld {  
  def main(args: Array[String]) {  
   print("Enter your name:")  
      val name = readLine()    
   if (name != null) println("Hello " + name + "!")  
  }  
 }  

compile it!
$> scalac HelloWorld.scala
By default scalac generates the class files into the current working directory. You may specify a different output directory using the -d option.

Execute it!
$> scala HelloWorld
scala allows us to specify command options, such as the -classpath (or -cp)

And the result:





This is just for fun. I'm more interested to use scala in web projects, as example by using play framework.

Tuesday, December 17, 2013

Get JPQL String From a NamedQuery in JPA

So, currently I'm working with 'pure' JPA, try to not to import any specific implementation to my Java project(s). Then, I has this problem. I have a query in NamedQuery JPA, called to fill a datatable in the UI.
The datatable itself using Primefaces, with sorting capability. I already built the sorting function, but the problem is: I need the JPQL to select which column to be sorted, not based on NamedQuery.

String queryString = getEntityManager().createNamedQuery(queryName).doSomethingHere() ///??
setSortOrderInfoForQuery(queryString); // sorting here
Query queryObject = getEntityManager().createQuery(queryString);

But I later I found out that no single implementation, every implementation have different function. It's explained very clear in Antonio Goncalves blog.

For the reason of efficiency (and backup) I'm copied here, what Antonio's conclusion in his blog (all credits to him):

Conclusion

As you can see, it’s not that simple to get a String representation for a TypedQuery. Here is a digest of the three main ORMs :
ORM FrameworkQuery implementationHow to get the JPQL StringHow to get the SPQL String
EclipseLinkJpaQuerygetDatabaseQuery().getJPQLString()*getDatabaseQuery().getSQLString()**
HibernateQueryN/AgetQueryString()
OpenJPAQueryImplgetQueryString()N/A
(*) Only possible on a dynamic or named query. Not possible on a CriteriaQuery
(**) You need to execute the query first, if not, the value is null
To illustrate all that I’ve written simple test cases using EclipseLinkHibernate and OpenJPA that you can download from GitHub. Give it a try and let me know.

And what about having an API in JPA 2.1 ?

For a developers’ point of view it would be great to have two methods in the javax.persistence.Query (and therefore javax.persistence.TypedQuery) interface that would be able to easily return the JPQL and SQL String representations, e.g : Query.getJPQLString() and Query.getSQLString(). Hey, that would be the perfect time to have it in JPA 2.1 that will be shipped in less than a year. Now, as an implementer, this might be tricky to do, I would love to ear your point of view on this.
Anyway, I’m going to post an email to the JPA 2.1 Expert Group… just in case we can have this in the next version of JPA ;o)


And since his article is from 24/05/2012, I think the standard API (function) is still not implemented :(

Update: And what's the workaround? Don't use named query, as simple as that.

Monday, October 21, 2013

Change @author Property in Netbeans

To change @author property in Netbeans:

  • go to Tools -> Templates

  • Click Settings
  • And change

Now, @author will pick "Desson Ariawan <teodesson yahoo.com>"

Wednesday, June 19, 2013

The Programmer

Kevlin Henney talk about The Programmer in Devoxx UK 2013

About The Programmer:
Somewhere in the heart of a development process, essential to the very being of a product's existence,
are the people who write, consider and wrestle with code. What motivates and demotivates them?
What are the intellectual challenges and rewards? What are the skills they have and need and
cognitive biases and environment they work with and against? This talk considers the act of
programming and those who do it and want to get better at it, from the perspective of development
process to craft, from architecture to code. 

If you have time, watch Kevlin's presentation to get a new perspective about The Programmer.
Now I'm not calling myself a developer again, I'm a programmer.

Sunday, May 12, 2013

To Check if Your Linux/Machine is 32 bit or 64 bit

Sometimes people forward me an address of machine I need to maintain. For windows it's pretty easy, just right click on 'Computer' and choose 'Properties'. But some of them it's linux that I need to maintain through ssh. Although normally our application requested a 64 bit environment, but that's not always the case. I need to check if the environment fit our needs.
"uname -a" will give me a pretty long information

Linux tiny-ubuntu 3.8.0-19-generic #30-Ubuntu SMP Wed May 1  16:35:23 UTC 2013
x86_64 x86_64 x86_64 GNU/Linux

We just need a fraction of those information only, "uname -m" will produce:
x86_64 for 64-bit kernel
i686      for 32-bit kernel

But remember, we can have a 32-bit Linux installed in 64-bit CPU, I never try the other way around...
So, checking CPU information, you can achieve it by using this command:"cat /proc/cpuinfo"

desson@tiny-ubuntu:~$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 58
model name      : Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz
stepping        : 9
cpu MHz         : 2489.318
cache size      : 6144 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl pni monitor ssse3 lahf_lm
bogomips        : 4978.63
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

Sunday, February 17, 2013

iPad+Linode+Internet for Development

My current laptop is an i7 Acer Aspire V3-571G which I upgraded to 16GB of memory. I code in Java (and MySQL) using Netbeans, using Ubuntu in VirtualBox.

Compared to me, this guy "setup" is quite crazy: iPad+Linode and of course with internet connection

The Setup:
  1. iPad 2 (16Gb, WiFi)
  2. Apple wireless keyboard
  3. Stilgut adjustable angle stand/case
  4. iSSH
  5. Linode 512 running Ubuntu 11.04
  6. Apple VGA adapter
And using Vim.

I really enjoying (and envy) the pictures (and freedom)

Monday, January 21, 2013

(Java) Development Stack 2013

Working in the new company focusing in the Java and Open Source framework made me to redefined my development stack. Here is the stack that I use per January 2013. It's not static (fixed), it may change in the future depending on the advancing technology.

Presentation Layer
Depending on the nature of the project (urgency). My default stack is to use JSF 2.1 with Primefaces components for rapid development. I also make use of Primefaces Extensions, especially for InputNumber. Yes, kinda shocking that Primefaces don't have InputNumber control. For templating, for sure Facelets is chosen. Don't mess anymore with JSP!
Sometimes I want something simple and flexible. For that purpose, I use Spring MVC with Angular.JS and Twitter Bootstrap.
Those two are mainstream frameworks, and represent component-based frameworks (JSF), and request-based frameworks (Spring MVC)
I also evaluating ZK. It has very interesting presentation, windows-like UI. It's the web UI frameworks used in Adempiere web UI. But for this moment, mastering JSF and Spring MVC has more value (for me) than adding extra effort to learning another (3rd) framework. Especially if my hand already full.

Business Layer
Mainly, I'm using Spring Framework to orchestrate transaction and integration with various data access layer, integration with presentation layer, messaging systems, even for security (Spring Security).
But, It's good to understand the standard, which is the 'pure' Java EE. I'm using Java EE 6 (with EJB 3.1) in several fun projects. The good thing is, JSF is the standard Java EE presentation layer. For security in Java EE, I'm evaluating Apache Shiro.

Data Access Layer
Hibernate is my choice (maybe I too attached with Hibernate's Criteria). I also use standard JPA (Eclipselink), but feel that JPA is too limited.
Although using iBatis.NET in my .NET projects, I never use iBatis (or MyBatis now) in Java. If there is a need for low level SQL, I'll use Spring JDBC.

Build
Currently using Maven 2.2.1, not Maven 3.x.x

Testing
Currently using TestNG for testing Spring application, and Arquillian for testing Java EE application (normally in embedded glassfish)
Currently evaluating and learning about Jacoco for code coverage, and Sonar(qube) for code quality. Both will be used as maven-plugin.

Application Server
I use Tomcat 7.0.26 for development and production. Yes, if you notice, it's specific version, it's the Tomcat versions bundled in Ubuntu 12.04 LTS. I also use Glassfish, especially for Java EE projects.

Database Server
For development and production, I use MySQL. Sometimes I use PostgreSQL (hey, we are mainly using Hibernate, changing database is not a problem), but the tools available for MySQL buy me over.
I'm using SQLyog Community Edition and Toad For MySQL (freeware) for development. If you are want it on Linux, simple; use wine

Source Control
Pretty much I'm using almost everything from SVN, Mercurial, and Git. It's also related to project hosting service we're used, either Github (Git), or Bitbucket (Git, Mercurial). Although Github more famous, Bitbucket allowed users to create unlimited private repository (it's pay service in Github).

Linux?
Yes, I'm using Linux. Currently using Ubuntu 12.04 LTS (Precise Pangolin).

What do you think compared to this?