>Nothing obviously wrong in what you have given so far.<
That's good news. At least I'm not totally off track!
> you will have to show a bit more code than that....<
here it is:
public class JWBDemo {
private static SessionFactory sf;
private static Datastore ds;
private static Session myS;
public static void main( String[] no_args ) throws Exception {
ds = Hibernate.createDatastore()
.storeClass(Edge.class)
.storeClass(Vertex.class)
.storeClass(Department.class);
sf = ds.buildSessionFactory();
Session myS = sf.openSession();
doDept();
}
public static void doDept() throws Exception {
String name = null;
List depts = null;
Department aDept = null;
String Id = new String ("A00");
try {
depts = myS.find(
"from Department in class boring.sandbox.Department" );
Iterator it = depts.iterator();
aDept = (Department) it.next();
name = aDept.getName();
System.out.println(aDept);
}
catch (Exception e){
e.printStackTrace();
}
}
-----Original Message-----
From: Gavin King [mailto:[EMAIL PROTECTED]
Sent: Monday, September 30, 2002 2:12 PM
To: Boring, Jeff W, ALBAS; [EMAIL PROTECTED]
Subject: Re: [Hibernate] NullPointerException on Session.find
Hmmmm. not sure. you will have to show a bit more code than that....
Nothing obviously wrong in what you have given so far.
----- Original Message -----
From: "Boring, Jeff W, ALBAS" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 01, 2002 3:58 AM
Subject: [Hibernate] NullPointerException on Session.find
> Help!!!!
>
> Newbie here trying some basic code and getting a nullpointer on the find.
I know it is something stupid I'm doing. Thanks for any help.
>
> Code is:
>
> depts = myS.find("from Department in class boring.sandbox.Department" );
>
> ---------------------- console ----------------------
> [INFO] DatastoreImpl - -Mapping resource: cirrus/hibernate/eg/Edge.hbm.xml
> [INFO] XMLHelper - -Parsing XML: unknown system id
> [INFO] DatastoreImpl - -Mapping resource:
cirrus/hibernate/eg/Vertex.hbm.xml
> [INFO] XMLHelper - -Parsing XML: unknown system id
> [INFO] Environment - -loaded properties from resource hibernate.properties
> [INFO] Environment - -echoing all SQL to stdout
> [INFO] Environment - -using java.io streams to persist binary types
> [INFO] Environment - -JVM proxy support: true
> [WARN] Collection - -Attribute "order-by" ignored in JDK1.3 or less
> [WARN] Collection - -Attribute "order-by" ignored in JDK1.3 or less
> [INFO] DatastoreImpl - -Mapping resource:
boring/sandbox/Department.hbm.xml
> [INFO] XMLHelper - -Parsing XML: unknown system id
> [INFO] Dialect - -Using dialect: class cirrus.hibernate.sql.DB2Dialect
> [INFO] DriverManagerConnectionProvider - -Hibernate connection pool size:
2
> [INFO] DriverManagerConnectionProvider - -Using driver:
COM.ibm.db2.jdbc.app.DB2Driver at URL: jdbc:db2:sample
> [INFO] DriverManagerConnectionProvider - -Connection properties:
{user=hibernate, password=thisIsStupid!}
> [INFO] PreparedStatementCache - -prepared statement cache size: 100
> [INFO] SessionFactoryImpl - -Use outer join fetching: true
> [INFO] SessionFactoryImpl - -Use scrollable result sets: true
> [INFO] SessionFactoryImpl - -Use JDBC 2 batch updates: false
> [WARN] SessionFactoryObjectFactory - -no JDNI name configured
> [INFO] SessionFactoryImpl - -Query language substitutions: {false=0,
no='N', yes='Y', true=1}
> [INFO] SessionFactoryImpl - -Query language imports: cirrus.hibernate.test
> java.lang.NullPointerException
> at boring.sandbox.JWBDemo.doDept(JWBDemo.java:50)
> at boring.sandbox.JWBDemo.main(JWBDemo.java:38)
> ---------------------- console ----------------------
> ---------------------- Department.java ----------------------
> package boring.sandbox;
> public class Department {
> private String name = null;
> private String number = null;
> private String location = null;
>
> public void Department(){
> }
>
> public String getName(){
> return name;
> }
> public String getNumber(){
> return number;
> }
> public String getLocation(){
> return location;
> }
> public void setName (String parm){
> name = parm;
> }
> public void setNumber (String parm){
> number = parm;
> }
> public void setLocation (String parm){
> location = parm;
> }
> }
> ---------------------- Department.java ----------------------
>
> ---------------------- DB Table DDL ----------------------
> CREATE TABLE "DB2ADMIN"."DEPARTMENT" (
> "DEPTNO" CHAR(3) NOT NULL ,
> "DEPTNAME" VARCHAR(29) NOT NULL ,
> "MGRNO" CHAR(6) ,
> "ADMRDEPT" CHAR(3) NOT NULL ,
> "LOCATION" CHAR(16) )
> IN "USERSPACE1" ;
>
> ALTER TABLE "DB2ADMIN"."DEPARTMENT"
> ADD CONSTRAINT "PKEY" PRIMARY KEY
> ("DEPTNO");
> ---------------------- DB Table DDL ----------------------
>
> ---------------------- Department.hbn.xml ----------------------
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC
> "-//Hibernate/Hibernate Mapping DTD//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping.dtd">
>
> <hibernate-mapping>
>
> <class name="boring.sandbox.Department" table="department"
schema="db2admin">
>
> <!-- comment -->
> <id column="DEPTNO" name="number" type="string">
> <generator class="assigned"/>
> </id>
>
> <property name="name" column="DEPTNAME" type="string" />
> <property name="location" column="LOCATION" type="string" />
>
> </class>
>
> </hibernate-mapping>
> ---------------------- Department.hbn.xml ----------------------
>
> Jeff Boring
> Custom & Web Services Development
> AT&T Labs
> [EMAIL PROTECTED]
> (813) 878-3367
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> hibernate-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/hibernate-devel
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel