Create a primary key column with sequence generated value in hibernate
Tech-Today

Create a primary key column with sequence generated value in hibernate


For example you have a class User:

package org.kalidad.seamexercises.model;


import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "USER")
@SequenceGenerator(sequenceName = "USER_SEQ_ID_GENERATOR", name = "USER_SEQ_ID_GENERATOR")
public class User implements Serializable {
private static final long serialVersionUID = 4707868996148508582L;
private long id;
private String name;
private String username;
private String password;

public User() {

}

@Column(name = "ID")
@javax.persistence.Id
@GeneratedValue(generator = "USER_SEQ_ID_GENERATOR")
public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

@Column(name = "NAME")
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Column(name = "USERNAME")
public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

@Column(name = "PASSWORD")
public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

}




- How To Protect Your Page Using Webfilter In Javaee
This tutorial is to be use in conjunction with picketlink. Normally we want some pages to be accessible only after a user has logged in. In this case we need a real protection filter. The class below filters a url path and check if there's a logged...

- How To Send And Receive Stomp Message In Jboss 7.2
The following code is an example of how we can send and receive a stomp message with JBoss 7.2. package org.meveo.util; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import java.util.Properties; import javax.naming.InitialContext;...

- Loading Locale From Post/get Parameter
This page will summarize how to load a resource bundle dynamically from a GET/POST parameter.  1.) In your mail xhtml template, make sure that you define f:view locale before the h:body tag: <f:view locale="#{languageBean.currentLocale}" />...

- How To Use Shiro With Jdbc On Javaee6 And Glassfish
Before you proceed with this tutorial, it's best to from this link to know how to setup a JavaEE6 project with Shiro integrated: http://czetsuya-tech.blogspot.com/2012/10/how-to-integrate-apache-shiro-with.html From there we will focus on the changes:...

- Creating Your First Ejb3 Project In Eclipse On Jboss Server
This tutorial will teach you on how to setup and run an ejb application. What you need (noted are where I installed my versions): 1.) Jboss 5 (jboss-5.1.0.GA) 2.) eclipse-jee 3.) ojdbc14 (C:\jboss-5.1.0.GA\server\default\lib) Steps: 1.) Create a new EJB...



Tech-Today








.