-->
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.  [ 2 posts ] 
Author Message
 Post subject: how to get back comments (column) from oracle db
PostPosted: Tue Jun 17, 2008 3:33 am 
Newbie

Joined: Tue Jun 17, 2008 3:23 am
Posts: 5
Hi I'm a Newbie on hibernate, and I want to get back the comments from each column and to put it on each object, I use Oracle 10g and I don't known how to do it. Any idea ? Thx for any help.
manos


Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 4:43 am 
Beginner
Beginner

Joined: Tue Dec 12, 2006 6:43 am
Posts: 32
Location: London
Hi,

Try to get DatabaseMetaData from


Code:

Connection conn =session.connection();

// Get DatabaseMetaData
      DatabaseMetaData dbmd = conn.getMetaData();

      // Get all column types for the table "ITEM", in schema
      // "dbo" and catalog "test".

     /*
     The below will return a Resultset contains rows and each rows contain      column description. Try to interogate the result set  for one row to see where is the column comment. The below is a sample which is missing some columns interogation ( col 5, etc...)
 

      */
      ResultSet rs = dbmd.getColumns("test", "dbo", "ITEM", "%");

      // Printout table data
      while(rs.next())
      {
          // Get dbObject metadata
          String dbObjectCatalog = rs.getString(1);
          String dbObjectSchema = rs.getString(2);
          String dbObjectName = rs.getString(3);
          String dbColumnName = rs.getString(4);
          String dbColumnTypeName = rs.getString(6);
          int    dbColumnSize = rs.getInt(7);
          int    dbDecimalDigits = rs.getInt(9);
          String dbColumnDefault = rs.getString(13);
          int    dbOrdinalPosition = rs.getInt(17);
          String dbColumnIsNullable = rs.getString(18);

          // Printout
          System.out.println("Col(" + dbOrdinalPosition + "): " + dbColumnName
                    + " (" + dbColumnTypeName +")");
          System.out.println("   Nullable: " + dbColumnIsNullable +
                    ", Size: " + dbColumnSize);
          System.out.println("   Position in table: " + dbOrdinalPosition
                    + ", Decimal digits: " + dbDecimalDigits);
      }

      // Free database resources
      rs.close();
      conn.close();








Please refer to java API for further details from the link below for further details

[url]http://java.sun.com/j2se/1.5.0/docs/api/java/sql/DatabaseMetaData.html
[/url]


Regards

_________________
Alan Mehio
London
UK


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