- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 - 41
 - 42
 - 43
 - 44
 - 45
 - 46
 - 47
 - 48
 - 49
 - 50
 - 51
 - 52
 - 53
 - 54
 - 55
 - 56
 - 57
 - 58
 - 59
 - 60
 - 61
 - 62
 - 63
 - 64
 - 65
 - 66
 - 67
 - 68
 
                        public class Tm_SP_RP extends Tm_Service implements IObject{
	private static final String m_MsgProfileStore =
		"UPDATE TM_SP_RP SET strMsgProfile=? WHERE nServiceID=?";
	private static final String m_WorkaroundHack =
		"SELECT data_type FROM user_tab_columns WHERE table_name='TM_SP_RP' AND column_name='STRMSGPROFILE'";
	private String strMsgProfile = null;
/* Здесь ещё разные всякие методы */
        private static String getWorkaroundType(Connection conn) throws SQLException
    {
    	PreparedStatement stmt = conn.prepareStatement(m_WorkaroundHack);
    	try
    	{
    		ResultSet rset = stmt.executeQuery();
    		try
    		{
    			if (!rset.next())
    				return "VARCHAR2";
    			return rset.getString(1);
    		}
    		finally
    		{
    			if (rset != null)
    				rset.close();
    		}
    	}
    	finally
    	{
    		if (stmt!=null)
    			stmt.close();
    	}
    }
	public void storeMsgProfile(Connection conn) throws SQLException
	{
		String w_around = getWorkaroundType(conn); 
		
    	PreparedStatement stmt = conn.prepareStatement(m_MsgProfileStore);
    	try
    	{
    		if (w_around.equalsIgnoreCase("VARCHAR2") ||
    			w_around.equalsIgnoreCase("VARCHAR"))
    		{
    			if (strMsgProfile == null)
    				stmt.setNull(1, Types.NULL);
    			else
    				stmt.setString(1, strMsgProfile);
    		}
    		else
    		{
    			byte []data = (strMsgProfile == null) ?
	    				new byte[0] : strMsgProfile.getBytes();
	    		stmt.setBytes(1, data);
    		}
    		
    		stmt.setLong(2, this.getId());
    		
    		stmt.executeUpdate();
    	}
    	finally
    	{
    		if (stmt!=null)
    			stmt.close();
    	}
	}
}
                                 
        
            Комбинация из багованных JDBC-дров Oracle и работающего с ним Hibernate (чтоб он сдох) иногда заставляет рождать вот такие хитрые workaround-хаки. Несколько баз, в одной тип поля - LONG, в другой - VARCHAR2.
        
        
Хотя, несмотря на мое непонимание, такой подход тоже имеет право на жизнь.