Tag Archives: oracle

oracle read queue jms data

queues… only triggers are more confusing… ok thats wrong… because i learned stuff about queue_schedulers… pretty scary… but thats something completely different and i actually hope, i dont have to write about these… but back to queues…

queue handling is in my point of view pretty strate forward… define a queue message, write a queue writer to put messages in the queue, write a reader to retrieve the messages from the queue… simple… but checking, whats acutally going on on the queue is difficult…

we have sys_aq$_jms_text_messages in the queue, which is actually shown on the queue_table when you do a select on it… great… so how can i get its content?

select msgid, enq_time, enq_uid, qt.user_data.TEXT_VC from MY_QUEUE_TABLE qt where q_name = ‘my_queue’

where as the qt needs to be written out…

timestamp with jpa

so i have my jpa project with some really nice DAOs and i was really happy… all unit tests are up and running and everything looked good… but it wasnt…

i store timestamp(6) in the oracle db and the mapping class looks good and correct:

@Column(name = “TIME_ADDED”)
@Temporal(TemporalType.DATE)
private Date timeAdded;

the @Temporal defines the mapping type… and actual DATE is really only the date… TIMESTAMP is the thing i wanted…

The @Temporal annotation denotes, whether annotated property should be mapped to java.sql.Date (holds only date part), java.sql.Time (holds only time part) or to java.sql.Timestamp (holds date and time also with fractions of second). It has nothing to do with generation of property value.
(http://stackoverflow.com/questions/2591570/hibernate-reverse-engineering-procedure-generated-temporaltemporaltype-timestam)

and btw. unit tests will not find these errors… due to jpa caching… 🙁

jpa mapping

java <-> oracle… with jpa sounds really easy, but was not… ok not really, because i just didnt get the whole thing… a problem was the naming… java class naming is different the database entities… so i needed to add mapping keywords…

@Entity
@Table (name=”<tablename>”, schema=”<schemaname>”)
public class <classname>{

@Id
@Column(name=”<colname>”)
private int id;

ok that was the simple part 🙂 the really hard part was the autoincrement… jpa allows different types of generatedValues and mainly it needs a specified sequence or trigger… the trigger is an absolute no go… and mapping sequence is wired… ok not soooo wired, but…

@Id
GeneratedValue(strategy = GenerationType.SEQUENCE, generator = “<sequenceName>”)
@SequenceGenerator(name = “<sequenceName>”, initialValue = 1, allocationSize = 1)
@Column(name=”<colname>”)
private int id;

the strategy needs an generator, which know the sequence and its behavior… and allocationSize is the increment value… which is 50 as default…

odbc oracle connection windows

so i needed a odbc to oracle… sounds easy… was confusing and actually i dont know, what i did nor if it was a good solution…

simplest way should be downloading the Oracle 11g Client for Windows… but wait… this fucking this is 2GB big… wtf? so tried it with the Instant Client (50MB) and the odbc supplement (700KB)… installing these things is kinda easy… but what the hell it is i dont know… ok its a driver… hurray… but how does the connection work? dont know… after googling around a lot i finally found this… opened notepad, created the files… set variables… and actually could configure the connection… hurray… and it actually works 🙂

is this a good solution?

ea oracle datatypes

as i told you before… working with enterprise architect and creating a database model for an oracle 11g database… and ea doesnt have the “timestamp” datatype… wft? so tried to figure out, if there is an ea update for newer oracle platforms… fail… but found this… exactly the same problem…

and a really simple solution… just define a new datatype:

Menu Settings->Database Datatypes

And define the database type for oracle…

simple… but spooky…