File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hiberante annotations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hiberante annotations" Watch "Hiberante annotations" New topic
Author

Hiberante annotations

rani vini
Greenhorn

Joined: May 13, 2009
Posts: 24
Is Hibernate will create schema also? Say I am writing one POJO class TEST and there is no table with name "TEST".
The following will create Table "TEST" in DB?
@Entity
public class Test {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
long id;
private String chin ;
private String emr ;

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

public long getId() {
return id ;
}

public void setChin(String chin) {
this.chin = chin;
}

public String getChin () {
return chin;
}

public void setEmr(String emr) {
this.emr = emr;
}

public String getEmr () {
return emr;
}

}
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Hibernate can generate DDL. See the configuration options for hibernate.hbm2ddl.auto.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Bhagat Singh Rawat
Ranch Hand

Joined: Apr 04, 2009
Posts: 93
Add the following line in your hibernate.cfg.xml and execute your application:
<property name="hbm2ddl.auto">create</property>

But the disadvantage of this property is it will create schema every time whenever you restart your application. You will be lost your stored data. If you don't want to use this property then just change it to:
<property name="hbm2ddl.auto">none</property>


Brainbench Java 2.0 Fundamentals, J2EE 1.4
http://www.brainbench.com/transcript.jsp?pid=8192792
rani vini
Greenhorn

Joined: May 13, 2009
Posts: 24
Thanq Bhagat
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Bhagat, are you aware this configuration option accepts a value of "update" too?
Bhagat Singh Rawat
Ranch Hand

Joined: Apr 04, 2009
Posts: 93
Paul Sturrock wrote:Bhagat, are you aware this configuration option accepts a value of "update" too?


Yes Paul here is the list:

validate | update | create | create-drop

I know why are you asking this question because I am using none in my above example
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hiberante annotations