I have this setting in the hibernate.cfg.xml
<property name="hibernate.hbm2ddl.auto">update</property>
and defined a class like this
Code:
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Table;
@Entity
@javax.persistence.Table(name="testtable")
@Table(appliesTo="testtable",indexes={@Index(name="idx",columnNames={"edad","nombre"})})
public class Prueba extends model {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long serial;
private String nombre;
private int edad;
...
I want to create the table at the start of the process.
But If I don't put the javax.persistence annotation, I get an exception telling me that table points to an unknown table.
Also I'd like to create the table with the columns in that order. but the table is generated with its columns in alphabetical order. (If it's pre-generated the order is respected,but I don't have that posibility)
Also Indexes are not being created.
What could be happening here?
I use Hibernate annotations 3.4.0.GA and Mysql 5.1.46