-->
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.  [ 3 posts ] 
Author Message
 Post subject: Dynamic mapping and Index
PostPosted: Tue Sep 26, 2006 1:58 pm 
Newbie

Joined: Tue Sep 26, 2006 1:43 pm
Posts: 6
Hi All,

I am adding new columns to my entity with Hibernate API:
Code:
<hibernate-mapping>
    <class entity-name="Patient">
        <id name="id"
            type="long"
            column="ID">
            <generator class="native"/>
        </id>
    </class>
</hibernate-mapping>





Looking for the manuals/samples gave me something like this:
Code:
Property property = new Property();
property.setName("test");
property.setNodeName(property.getName());

PersistentClass persistentClass = onfiguration.getClassMapping("Patient");

SimpleValue value = new SimpleValue(persistentClass.getTable());
value.setTypeName("string");

Column column = new Column("TABLE_COLUMN");
persistentClass.getTable().addColumn(column);
value.addColumn(column);

property.setValue(value);

persistentClass.addProperty(property);




That works fine, but now I am trying to add Index :(
I've tried something like this:
Code:
Index index = persistentClass.getTable().getOrCreateIndex("MY_INDEX");
index.addColumn(column);

or this:
Code:
Index index = new Index();
index.setName("MY_INDEX");
index.addColumn(column);
persistentClass.getTable().addIndex(index);

There are no error messages, but it doesn't create the Index in the table :'(
Could someone help me a bit?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 11:20 am 
Newbie

Joined: Tue Sep 26, 2006 1:43 pm
Posts: 6
Nobody knows? :(


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 12:47 pm 
Newbie

Joined: Tue Sep 26, 2006 1:43 pm
Posts: 6
The code was correct, the answer can be found in this thread:

http://forum.hibernate.org/viewtopic.ph ... ndex+mysql

Hibernate doesn't create Indexes with
Code:
properties.setProperty("hibernate.hbm2ddl.auto", "update");


Should be:
Code:
properties.setProperty("hibernate.hbm2ddl.auto", "create");


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.