I am new in spring mvc and i am trying to make db table using annotation. but it is not creating when i use hbm.xml it works properly. Please help me. any help will be appriciable.
My form coding is:-
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotEmpty;
@Entity
@Table(name = "LOGIN_MASTER")
public class LoginForm {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long Id;
@NotEmpty
@Size(min = 1, max = 50)
@Column(name = "userName")
private String userName;
@NotEmpty
@Size(min = 1, max = 20)
@Column(name = "password")
private String password;
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return userName;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}
public long getId() {
return Id;
}
public void setId(long id) {
Id = id;
}
}
hibernate.cfg.xml
<session-factory>
<property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/spring3login</property>
<property name="hibernate.connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.pool_size">1</property>
<property name="hibernate.dialect"> org.hibernate.dialect.HSQLDialect </property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>
spring.xml
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix"> <value>/WEB-INF/views/</value> </property>
<property name="suffix"> <value>.jsp</value> </property>
</bean>