Viral Patel

org.hibernate.AnnotationException: No identifier specified for entity

When you are writing a piece of code from scratch a lot of time you do silly mistakes and still wonder why its not working. Well same thing happened the other day when I added a Hibernate Entity class in one project and was struggling to make it work.The exception was:org.hibernate.AnnotationException: No identifier specified for entity: net.viralpatel.hibernate.Employee at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:650) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1112) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:416) at ...

Android: Trigger Media Scanner Programmatically

Android: Trigger Media Scanner Programmatically
While working on an Android App, I had to integrate the Camera API. User can take a photo from App and process it. With Android the Photo that you click cannot be accessed until the media scanner runs and index it. It is possible to triggeer programatically the Media Scanner in Android. Check the below code snippet:import android.content.Intent; import android.net.Uri; import android.os.Environment; ... ... sendBroadcast( new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())) ); ...Here ...

How To Enable Camera in Android Emulator

How To Enable Camera in Android Emulator
By default when you create an Android Virtual Devices (AVD) in Android, the Camera is disabled. So if your application uses Camera API, it might not work properly in Android Emulator. Also SDCard must be defined in emulator in order to use Camera.To enable Camera in your Android Emulator, just add following highlighted code in your AVD's config.ini file. You can find the config.ini ...

How to Resize Image Dynamically in PHP

Today almost every website you visit show content in form of thumbnails. Thumbnails are nothing but images displayed next to the content. Be it News website or a blog, displaying images next to content is key to appeal user. Even our blog shows images as thumbnails on home page.A prerequisites to show Thumbnail in a ...

How To Pick Image From Gallery in Android App

How To Pick Image From Gallery in Android App
Since few days I am working on an Android app and learning all the nitty gritty of its APIs. I will share few How-to stuffs that we frequently require in Android.To start with let us see how to integrate Image Gallery with your App. Consider a requirement, you want your app user to select Image from the Gallery and use that image to do some ...

How To Iterate HashMap in FreeMarker (FTL)

In this short article we will see how to iterate an HashMap in FreeMarker template. Consider below code which is normally used to iterate a List in FTL.//Java List<String> cityList = new ArrayList<String>(); cityList.add("Washington DC"); cityList.add("Delhi"); cityList.add("Berlin"); cityList.add("Paris"); cityList.add("Rome"); request.setAttribute("cityList", cityList); //FTL template <#list cityList as city> <b> ${city} </b> </#list>Output:Here in above code, we created a List object and passed it to FTL page. In FTL we used ...

Batch Insert In Java – JDBC

Let's see how we can perform batch insert in Java using JDBC APIs. Although you might already knew this, I will try to explain the basic to a bit complex scenarios.In this note, we will see how we can use JDBC APIs like Statement and PreparedStatement to insert data in any database in batches. Also we ...

Convert Arrays to Set in Java

Java Collection API is one of the most useful APIs used in any Java application. In my day to day Java coding routine, I have to deal with these APIs quite often.However sometime while working with Collection API, lot of developers end up writing unnecessary and mostly inefficient code. For example, to convert an Java ...

STOP SOPA JQuery Plugin

STOP SOPA JQuery Plugin
Right now, Internet is experiencing the biggest protest since its inception. We have seen people protesting against Companies, Government, Dictators etc. Also Internet has become their voices in form of Twitter & Facebook.But today we saw something completely new. Major websites such as Wikipedia and Google are openly demonstrating their protest against new legislation bills ...

How To Create QR Codes in Java & Servlet

How To Create QR Codes in Java & Servlet
Nowadays, Quick Response (QR) Codes are becoming more and more useful as they have gone mainstream, thanks to the smart phones. Right from the bus shelter, product packaging, home improvement store, automobile, a lot of internet websites are integrating QR Codes on their pages to let people quickly reach them. With increase in number of users of smart phones day by day, the QR codes ...
Page 1 of 2812345...1020...Last »