-->
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.  [ 4 posts ] 
Author Message
 Post subject: Default schema being ignored using windows authentication.
PostPosted: Wed Mar 02, 2016 12:21 am 
Newbie

Joined: Wed Mar 02, 2016 12:04 am
Posts: 3
I have migrated a web application running on Wildfly 9 from using SQL authentication to using windows authentication. I also need to update a java utility that does some maintenance tasks directly on the database. The web application works fine, but the utility seems to ignore the default schema setting in the hibernate configuration. Tracing on the sql server shows the queries comming from wildfly have myschema.<table name> but the queryies from my utility have just <table name>.

There is a login (DOMAIN\myservice) on the SQL Server for the domain account that wildfly service runs under, and I run the util as the same account.

The login is mapped to a user on the database with the same name (DOMAIN\myservice).

The user has a default schema of dbo.

util-hibernate.cfg.xml
Code:
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServer2008Dialect</property>
        <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
        <property name="hibernate.connection.url">jdbc:sqlserver://sqlhost\INSTANCE:1433;databaseName=MYAPP;integratedSecurity=true</property>
        <property name="hibernate.connection.pool_size">5</property>
        <property name="hibernate.default_schema">myschema</property>
        <property name="hibernate.show_sql">true</property>

        <mapping resource="....hbm.xml"/>
        <mapping resource="...hbm.xml"/>
        ...
    </session-factory>
</hibernate-configuration>


war-hibernate.cfg.xml
Code:
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.datasource">jdbc/MYAPP</property>
        <property name="hibernate.default_schema">myschema</property>

        <mapping resource="....hbm.xml"/>
        <mapping resource="...hbm.xml"/>
        ...
    </session-factory>
</hibernate-configuration>


wildfly datasource

Code:
<datasource jndi-name="java:jdbc/MYAPP" pool-name="MyDataSource" enabled="true">
    <connection-url>jdbc:sqlserver://sqlhost\INSTANCE;databaseName=MYAPP;integratedSecurity=true</connection-url>
    <driver>sqljdbc4.jar</driver>
    <pool>
        <max-pool-size>10</max-pool-size>
    </pool>
    <validation>
        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker" />
        <validate-on-match>false</validate-on-match>
        <background-validation>true</background-validation>
        <background-validation-millis>30000</background-validation-millis>
    </validation>
</datasource>


In the logging for my utility I see:

Code:
SettingFactory:222 - Default schema: myschema


But further down I see the error:

Code:
com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name '<table name>'


Where the table is in myschema.

I have tried updating hibernate mapping files with:

Code:
<hibernate-mapping schema="myschema">
    <class name="MyType" table="table_name">

And

Code:
<hibernate-mapping>
    <class name="MyType" schema="myschema" table="table_name">


But that didn't work either.

Versions of things
    Wildfly 9.0.2.Final
    Hibernate 3.5.6-Final
    Microsoft SQL JDBC 4.1
    SQL Server 2014
    JRE 7u67


Top
 Profile  
 
 Post subject: Re: Default schema being ignored using windows authentication.
PostPosted: Wed Mar 02, 2016 3:31 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Does the web application use the same Hibernate version as the utility?


Top
 Profile  
 
 Post subject: Re: Default schema being ignored using windows authentication.
PostPosted: Wed Mar 02, 2016 6:58 pm 
Newbie

Joined: Wed Mar 02, 2016 12:04 am
Posts: 3
Yes the same.


Top
 Profile  
 
 Post subject: Re: Default schema being ignored using windows authentication.
PostPosted: Wed Mar 02, 2016 10:53 pm 
Newbie

Joined: Wed Mar 02, 2016 12:04 am
Posts: 3
I've solved the issue. It turns out the utility was using a SQLQuery that I hadn't noticed and it seems the default schema is not applied to that. Thanks for reading.


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