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.  [ 2 posts ] 
Author Message
 Post subject: Indexes with hbm mappings
PostPosted: Wed Mar 23, 2011 1:25 pm 
Newbie

Joined: Mon Mar 15, 2010 1:16 pm
Posts: 9
Hi,

I'm trying to create dynamic models and I can't get indexes to work. So far I've tested with PostgreSQL and SQLServer.

I'm configuring like this:
Code:
        Configuration cfg = new Configuration()
                .addFile(new File("Person2.hbm.xml"))
                .setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect")
                .setProperty("hibernate.connection.url", "jdbc:postgresql://localhost/hibernate")
                .setProperty("hibernate.connection.driver_class", "org.postgresql.Driver")
                .setProperty("hibernate.connection.username", "test")
                .setProperty("hibernate.connection.password", "test")
                .setProperty("hibernate.order_updates", "true")
                .setProperty("hibernate.hbm2ddl.auto", "update")
                .setProperty("hibernate.show_sql", "false");


        SessionFactory sessions = cfg.buildSessionFactory();

        Session session = sessions.openSession();


My Person2.hbm.xml is like:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
    <class entity-name="Person2" table="PERSON2">
        <id name="id" column="P_ID" type="long">
            <generator class="native"/>
        </id>
        <property name="age" type="integer" column="P_AGE" index="P_AGE_INDEX"/>
        <property name="firstname" type="string" column="P_FIRSTNAME"/>
        <property name="lastname" type="string" column="P_LASTNAME"/>
    </class>
</hibernate-mapping>


The I open the graphic PostgreSQL tool and there's no index created besides the one on the PK.

What do I have to do to get indexes working?

Thanks in advance,

Rui


Top
 Profile  
 
 Post subject: Re: Indexes with hbm mappings
PostPosted: Wed Mar 23, 2011 2:47 pm 
Newbie

Joined: Mon Mar 15, 2010 1:16 pm
Posts: 9
Ok... if I use create-drop policy it works. Anyone knows why?

--
Rui


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.