-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Problem with auto-generating tables
PostPosted: Thu Sep 11, 2008 4:20 am 
Newbie

Joined: Thu Sep 11, 2008 4:10 am
Posts: 4
Location: Philippines
Hi

Im trying to develop a very simple application using Spring and Hibernate Annotations, my application is already running it's just that im having problem with the auto-generation of tables, or should i say that theres is no table being generated when i run the application(im using Netbeans BTW). I really wanna learn many stuff and any help or suggestion is greatly appreciated...

here is may POJO...

@Entity
@Table(name="personnel")
public class Personnel implements Serializable {
private static final long serialVersionUID = 1L;

private String afpsn;
private String firstname;
private String lastname;
private String middlename;
private String appendage;
private String lengthservice;
private String unitassign;
private String homeaddress;
private String contactnumber;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public String getAfpsn() {
return afpsn;
}

public void setAfpsn(String afpsn) {
this.afpsn = afpsn;
}

@Column(name="middlename", length=30)
public String getMiddlename() {
return middlename;
}

public void setMiddlename(String middlename) {
this.middlename = middlename;
}

@Column(name="firstname", length=30)
public String getFirstname() {
return firstname;
}

public void setFirstname(String firstname) {
this.firstname = firstname;
}

@Column(name="lastname", length=30)
public String getLastname() {
return lastname;
}

public void setLastname(String lastname) {
this.lastname = lastname;
}

@Column(name="appendage", length=30)
public String getAppendage() {
return appendage;
}

public void setAppendage(String appendage) {
this.appendage = appendage;
}

@Column(name="contactnumber", length=30)
public String getContactnumber() {
return contactnumber;
}

public void setContactnumber(String contactnumber) {
this.contactnumber = contactnumber;
}

@Column(name="homeaddress", length=30)
public String getHomeaddress() {
return homeaddress;
}

public void setHomeaddress(String homeaddress) {
this.homeaddress = homeaddress;
}

@Column(name="lengthservice", length=30)
public String getLengthservice() {
return lengthservice;
}

public void setLengthservice(String lengthservice) {
this.lengthservice = lengthservice;
}

@Column(name="unitassign", length=30)
public String getUnitassign() {
return unitassign;
}

public void setUnitassign(String unitassign) {
this.unitassign = unitassign;
}
........



and here is my XML file...


<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/spring</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>password</value>
</property>
</bean>
<!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) !-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<!--property name="configLocation">
<value>WEB-INF/hibernate.cfg.xml</value>
</property-->
<property name="annotatedClasses">
<list>
<value>dao.gaydz.praktis.model.Personnel</value>
</list>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect" >org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

<bean id="txAttributeSource" class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="remove*">PROPAGATION_REQUIRED</prop>
<prop key="send*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

please help me out....tnx in advance


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 5:01 am 
Newbie

Joined: Fri Sep 09, 2005 11:09 am
Posts: 7
Location: Clermont-Ferrand
Hi,
Do you have any exception? If not, did you turn on log? (category "org.hibernate" with log4j)?

_________________
Mickael Gervais
Agaetis


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 5:04 am 
Newbie

Joined: Thu Sep 11, 2008 4:10 am
Posts: 4
Location: Philippines
nope i dont have any exception....im sorry, how do i know bout the log?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 5:29 am 
Newbie

Joined: Fri Sep 09, 2005 11:09 am
Posts: 7
Location: Clermont-Ferrand
Are you using a log system? Like log4j? If not add log4j.jar in your classpath, and add a log4j.xml in your jar with this content:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "log4j.dtd" "log4j.dtd">
<!-- =====================================================================    -->
<!--                                                                          -->
<!--                    Log4j Configuration                             -->
<!--                                                                          -->
<!-- =====================================================================    -->


<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
      <param name="target" value="system.out" />
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d [%t] %-5p %c %M - %m%n" />
      </layout>
   </appender>
   
   <category name="org.springframework">
      <priority value="TRACE" />
      <appender-ref ref="CONSOLE" />
   </category>
   
   <category name="org.hibernate">
      <priority value="TRACE" />
      <appender-ref ref="CONSOLE" />
   </category>

</log4j:configuration>


I'm using sporing and hibernate but with this bean:
Code:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">

_________________
Mickael Gervais
Agaetis


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 9:44 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
hi,

you can also compare your setup with the setup described on the wiki: http://www.hibernate.org/441.html.

However, understanding the logging and debugging capabilities - not only for Hibernate, but also the other used frameworks - is a must :)

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 9:52 pm 
Newbie

Joined: Thu Sep 11, 2008 4:10 am
Posts: 4
Location: Philippines
hey tnx for the help...please bear with me im just a beginner and i really wanna learn so please be patient in replying to my problem...


i am really confuse on where to put those line of codes, is it in the web.xml file? Honestly i don't know where to find the "classpath" in every application, i keep seeing it in the net but i really don't have a clear idea bout that...

i have my jog4j.jar in may application libraries but like i've said i really don't have a clear idea bot the classpath...

i'll be waiting again for some other help and please don't reply to technical, im just a begginer pls bear with me and i REALLY REALLY wanna learn


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2008 3:42 am 
Newbie

Joined: Fri Sep 09, 2005 11:09 am
Posts: 7
Location: Clermont-Ferrand
Hi,
you should read some tutorials.
For netbean classpath: http://www.netbeans.org/kb/55/using-net ... Id-1157099. Classpath is the list of your project's dependencies (jar), which include all java classes avaliable in you program.
For log4j, you just have to put the log4j.xml in the source folder.

_________________
Mickael Gervais
Agaetis


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2008 4:34 am 
Newbie

Joined: Thu Sep 11, 2008 4:10 am
Posts: 4
Location: Philippines
tnx again man....

hey just wanna know if this line has something to do with my problem...

log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.

that line is from the log or should i say console of glassfish in Netbeans. I have again browse on the internet and read some forum bout log4j, some dude say that you have to make a log4j.properties file to remove that line...I am confuse, my very simple application is running at Netbeans and displaying the default welcome page..the only thing is that i want it to generate the table in the database and unfortunately there is none...can you tell me what this log4j has something to do with that...
tnx again for helping me...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.