Q:

node to traverse cannot be null SQL SELECT

I have a problem with a query in HQL also my SQL base has some databases , so need to put together a query that take this table at the bottom, my sql base always starts in database 'database' and I must refer to the database webproduction then so I wrote my query :
@Entity
@Table(name="File")
@NamedQueries(

        {
            @NamedQuery(name="file.allList",
                    query = "use webproduction select * from File")
        }
)

My Config: 
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
        <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
        <property name="hibernate.connection.url">jdbc:sqlserver://10.11.1.05</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.connection.password"></property>

        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.format_sql">true</property>

        <!-- <mapping class="entity.Sell" /> -->
        <mapping class="entity.File" />

    </session-factory>
</hibernate-configuration>

My Class hibernate:
public class HibernateUtil {
    private static final SessionFactory sessionFactory;

    static {
        try {

            sessionFactory = new AnnotationConfiguration().configure(
                    "config/sql_hibernate.cfg.xml").buildSessionFactory();
        } catch (Throwable ex) {

            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }
}

My method:
public List<File> getFile() throws Exception{
        session = HibernateUtil.getSessionFactory().openSession();
        query = session.getNamedQuery("file.allList");
        List<File> list1 = query.list();

        session.close();

        return list1;
    }

A:

For SQL server you would remove the 'use webproduction' from your named query and use:
jdbc:sqlserver://10.11.1.05;DatabaseName=webproduction
as your hibernate.connection.url
see http://www.java2s.com/Tutorial/Java/0340__Database/AListofJDBCDriversconnectionstringdrivername.htm

