| Hi,
I am trying to insert an object with one to many mapping and I am getting the following exception
 -------------------------------------------------------------------
 
 java.lang.UnsupportedOperationException: The user must supply a JDBC connection
 at net.sf.hibernate.connection.UserSuppliedConnectionProvider.getConnect
 ion(UserSuppliedConnectionProvider.java:32)
 at net.sf.hibernate.impl.SessionFactoryImpl.openConnection(SessionFactor
 yImpl.java:396)
 at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:81)
 at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.ja
 va:59)
 at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:599)
 ----------------------------------------------------------------------
 I am trying to supply the java.sql.Connection object during runtime using the following code
 
 
 Configuration cfg=new Configuration();
 cfg.addClass(User.class);
 cfg.addClass(Purchase.class);
 SessionFactory sessionFac=cfg.buildSessionFactory();
 Class.forName("org.gjt.mm.mysql.Driver");
 Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/temp","root","xxxxx");
 Session sess=sessionFac.openSession(conn);
 Transaction tx=null;
 tx=sess.beginTransaction();
 sess.save(User);
 tx.commit();
 sess.close();
 ---------------------------------------------------------
 Following is the mapping of hibernate.properties file
 
 hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
 hibernate.connection.driver_class org.gjt.mm.mysql.Driver
 #hibernate.connection.driver_class com.mysql.jdbc.Driver
 hibernate.connection.url jdbc:mysql://localhost:3306/temp
 hibernate.connection.username root
 hibernate.connection.password xxxx
 hibernate.connection.pool_size 10
 ------------------------------------------
 Following are the mapping of user.hbm.xml and Purchase.hmb.xml
 User.hbm.xml
 <hibernate-mapping>
 <class
 name="User"
 table="user">
 <id
 name="userid"
 column="userid">
 <generator class="native"/>
 </id>
 
 <property
 name="useremail"
 column="useremail"
 not-null="true"
 unique="true"/>
 
 <bag
 name="purchase"
 table="purchase"
 inverse="true"
 lazy="true"
 cascade="all">
 
 <key column="userid"/>
 <one-to-many class="purchase"/>
 
 </bag>
 </class>
 
 </hibernate-mapping>
 --------------------------------------------------
 Purchase.hbm.xml
 <hibernate-mapping>
 <class
 name="Purchase" table="purchase">
 
 <id
 name="purchaseid"
 column="purchaseid">
 <generator class="native"/>
 </id>
 
 <many-to-one
 name="user"
 column="userid"
 not-null="true"/>
 
 </class>
 </hibernate-mapping>
 
 ---------------------------
 Any help would be highly appreciated
 Thanks
 
 
 |