Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • alius
    replied
    Originally posted by vostapenko View Post
    And everything works fine.
    Seems like the problem is only reproduced when dinamic mapping is generated from database table and hibernate.cfg.xml without any mapping is on classpass. That's exactly what was stated by Isomorphic a few posts earlier.
    Thanks for info.

    Originally posted by vostapenko View Post
    I think this testcase is very uncommon. But maybe it's worth mentioning in documentation, cause in theory someone can have some mappings generated from database tables and others - from hibernate beans.
    Agree. Docs will be updated in the future.

    Regards,
    Alius

    Leave a comment:


  • vostapenko
    replied
    Well, to my shame, i've renamed hibernate3.cfg.xml to hibernate.cfg.xml (and changed session factory config accordingly).

    And everything works fine.

    Seems like the problem is only reproduced when dinamic mapping is generated from database table and hibernate.cfg.xml without any mapping is on classpass. That's exactly what was stated by Isomorphic a few posts earlier.

    I think this testcase is very uncommon. But maybe it's worth mentioning in documentation, cause in theory someone can have some mappings generated from database tables and others - from hibernate beans.

    Leave a comment:


  • vostapenko
    replied
    Actually, i've lost interest to this problem, because renaming hibernate.cfg.xml works pretty well. If noone before experienced the same problem, maybe it's not even worth fixing.

    I'm now far ahead in the develpment and reproducing it againg with clean logs is gonna need some effort.

    I'll try to do it a little later.

    Your help is very appreciated anyway.

    Leave a comment:


  • alius
    replied
    Could you post your class, data source, hibernate.cfg.xml, related options from server.properties, related configuration from spring?
    Please post server log which you get with that configuration as well.

    Thanks,
    Alius

    Leave a comment:


  • vostapenko
    replied
    Code:
    You have to correct your data source definition
    I have correct definition. Earlier provided definition was in context of dinamic model (hibernate.cfg.xml did not contain any mapping, but the file was present).

    Code:
    <DataSource
        ID="users"
        serverType="hibernate"
        tableName="suser"
    >
    without mapping in hibernate.cfg.xml

    and

    Code:
    <DataSource
        ID="users"
        serverType="hibernate"
        beanClassName="com.smartgwt.mypackage.User"
    with mapping

    gives the same error we are already discussing - the problem of SmartGWT not ignoring hibernate.cfg xml, while full hibernate configureation is passed to it with the help of spring.

    Leave a comment:


  • alius
    replied
    Hi,

    You have to correct your data source definition:

    Code:
    <DataSource
        ID="users"
        serverType="hibernate"
        tableName="suser"    <--- remove this property
        beanClassName="com.smartgwt.mypackage.User"  <--- add this property
    >
        <fields>
            <field name="userid" title="ID" type="integer" primaryKey="true" required="true"/>
            <field name="userlogin" title="Login" type="text"/>
            <field name="userpassword" title="Password" type="text"/>
        </fields>
    </DataSource>
    Bit of explanation:
    "beanClassName" property specifies ORM mapped class which should be used in data source.
    If you specify only "tableName" property then data source does not know which class to use and tries to create mapping on the fly.

    Regards,
    Alius

    Leave a comment:


  • vostapenko
    replied
    Thx for your reply.

    The real problem was that your Spring configuration was incomplete - it lacked the required mapping.
    Well, from my point of view, my configuration was ok. Mapping was included in session factory bean declaration.

    Code:
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
            <property name="dataSource" ref="dataSource"/>
            [b]<property name="configLocation" value="classpath:hibernate.cfg.xml"/>[/b]
            <property name="hibernateProperties">
                <value>
                    hibernate.dialect=${hibernate.dialect}
                </value>
            </property>
        </bean>
    Your changes fixed the problem by making the mapping available through Spring - the fact that you renamed hibernate.cfg.xml was unimportant
    The only change i made was renaming config file to hibernate3.cfg.xml and changing corresponding config declaration to <property name="configLocation" value="classpath:hibernate3.cfg.xml"/>.

    So, to summarize, my configuration contained mapping from the beginning. The only change i made is renaming hibernate config. So i've never "corrected" my configuration as you state.

    Leave a comment:


  • Isomorphic
    replied
    What's actually going on here is that we loaded your configuration via Spring, but it did not contain a mapping for the class you specified in your DataSource.

    In this situation we assumed you wanted a dynamic mapping added (which is something the framework supports). The only way for us to add a dynamic mapping is to have the configuration expressed as a hibernate.cfg.xml file because the configuration returned by Spring is immutable.

    So the real problem was that your Spring configuration was incomplete - it lacked the required mapping. Your changes fixed the problem by making the mapping available through Spring - the fact that you renamed hibernate.cfg.xml was unimportant as it would not have been consulted anyway once you corrected your Spring config.

    Let us know if you disagree with this analysis - there doesn't appear to be a bug here but we might add some logs to make it clearer why you would see an attempt to rebuild the config.

    Leave a comment:


  • vostapenko
    replied
    hibernate.cfg.xml contains only mapping, e.g.

    Code:
    <hibernate-configuration>
        <session-factory>
            <mapping class="com.smartgwt.mypackage.User"/>
        </session-factory>
    </hibernate-configuration>
    All connection settings are moved to jdbc.properties, and read by PropertyPlaceholderConfigurer.

    PropertyPlaceholderConfigurer -> DataSource bean -> Sessionfactory bean.

    With this configuration, smartgwt tries to use hibernate.cfg.xml even it's clearly instructed to load config properties via spring (hibernate.config.lookupStyle: spring). It should completely ignore hibernate.cfg.xml.
    Last edited by vostapenko; 4 Sep 2012, 18:01.

    Leave a comment:


  • Isomorphic
    replied
    Can you clarify what the issue is - you seem to be saying an empty hibernate.cfg.xml on the classpath causes a problem, but now you seem to be using Spring to load settings from a hibernate.cfg.xml file that has been renamed but presumably has some settings in it.

    Are you trying to use *both* Spring-based config and a hibernate.cfg.xml file, but you don't want SmartGWT to read the hibernate.cfg.xml file directly?

    As far as support, we appreciate that your intent is to report bugs, however please realize that we have known bugs we can be working on. It's not uncommon to spend a lot of time helping someone who is having an odd problem only to discover there's no bug and not even a documentation clarification worth adding; when this happens the time would have been better spent on actual bugs.

    Also, don't believe everything you read. Fake reviews are very affordable these days, just like fake Twitter followers :)

    Leave a comment:


  • vostapenko
    replied
    Btw, the workaround for this is renaming hibernate.cfg.xml and changing sessionfactory declaration to something like

    Code:
        <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
            <property name="dataSource" ref="dataSource"/>
            <property name="configLocation" value="classpath:hibernate3.cfg.xml"/>
            <property name="hibernateProperties">
                <value>
                    hibernate.dialect=${hibernate.dialect}
                </value>
            </property>
        </bean>
    But you should definitely fix this issue, "hibernate.config.lookupStyle: spring" doesn't work with hibernate.cfg.xml on classpath with no config parameters inside.

    And, Isomorphic, pls don't be so haughty answering users questions. Your forum support already has bad rep across the internet. Try to change something. BTW i'm reporting bugs and making your product better, and i'm doing it for free.

    Leave a comment:


  • vostapenko
    replied
    From my point of view, the problem is caused by SmartGWT still caring about hibernate.cfg.xml even when

    Code:
    hibernate.config.lookupStyle: spring
    hibernate.config.bean: mySessionFactory
    is specified. I think SmartGwt should ignore hibernate.cfg.xml completely. I've attached new full logs with srping debug if you need them.

    Please confirm.
    Attached Files
    Last edited by vostapenko; 30 Aug 2012, 04:39.

    Leave a comment:


  • vostapenko
    replied
    Reproduced on 3.1d (SNAPSHOT_v8.3d_2012-08-30/Pro Deployment (built 2012-08-30))
    Last edited by vostapenko; 30 Aug 2012, 02:08.

    Leave a comment:


  • Isomorphic
    replied
    You are most likely running into a situation where Spring tries to initialize itself before SmartGWT even if configured for lazy creation - see this thread for a workaround. This workaround has already been applied for 3.1d.

    Leave a comment:


  • vostapenko
    replied
    Full log is attached to original message.

    users.ds.xml
    Code:
    <DataSource ID="users" serverType="hibernate" tableName="suser">
        <fields>
            <field name="userid" title="ID" type="integer" primaryKey="true" required="true"/>
            <field name="userlogin" title="Login" type="text"/>
            <field name="userpassword" title="Password" type="text"/>
        </fields>
    </DataSource>
    I've looked through "separate samples". In all samples (at least in sdk examples) hibernate is configured through hibernate.cfg.xml, so it's a different story and i'm reporting about the issue with hibernate.config.lookupStyle: spring
    Last edited by vostapenko; 29 Aug 2012, 15:55.

    Leave a comment:

Working...
X