Category Archives: Uncategorized

spring

in my project there are a lot of technologies involved and as a .net-developer everything is new… yeah… its java again 🙂 ok jpa, mule, spring, maven, pojos… and i finally understood the main concept of spring :)… or lets say the part with beans… ok i didnt understand, when (timewise) springbeans ware created… but i think this is kinda less important… ok its starts to be important, when something goes wrong, but can do…

 <bean id=”[objectId]” class=”[className]”>
<constructor-arg>
<value>[value]</value>
</constructor-arg>
</bean>

With this declaration an object of typ className will be generated with the name objectId. The constructor is filled with set values… the big question is: where the hell is this object? Actually i dont know, but it can be get in java with:

@Autowired
[className] [objectId];

done.

eclipselink with spring

we decided to use jpa with eclipselink… i actually think this was a good decition, but there are a few problems, when using it with spring… eclipselink needs a LoadTimeWeaver… which can only be loaded by spring, when run with an spring agent… add following argumentline to the VM arguments when run…

-javaagent:${where.ever.it.is}/spring-agent-2.5.6.jar

so unit test need this command… the question, how it will work with maven is completely different… and with mule its an other story…

mule with spring and testing without mule…

mule is able to import spring beans… as expected 🙂 but to test those… its kinda hard… 🙁

first create an own bean config file separated from the mule-config.xml and include it in mule-config.xml with following tags:

<spring:beans>
<spring:import resource=”beans.xml”/>
</spring:beans>

simple 🙂 now the beans.xml is a simple springbeans config file… with <beans> as root tag and <bean>’s inside. easy too…

and now use following annotation in the unittest:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={“classpath:beans.xml”})

this should now load the bean correctly during test…

jpa cache

ok the entityManager in jpa caches… which is normally a good thing… but with OneToMany / ManyToOne mapping its kinda wired… my problem is, that i have an object A and an object B… A has one B… B has a List<A>…

  1. so created a B and persisted it…
  2. created a A with the B object and persited it
  3. checked A and has B 🙂
  4. checked B and has an empty list 🙁

and everything is in one transaction… unit test… if i persist it B with A in the list.. it works… but DB looks exactly the same… so there is a cache…

how can i kill it? or is it really a problem?

see: http://en.wikibooks.org/wiki/Java_Persistence/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…

enterprise architect reverse engineering ddl

after finally get my odbc oracle connection running, it was time to try out the reverse engineering… loading a existing database in ea… and it works…

  1. Create a new, empty ea project
  2. Goto Projects->Database Engineering->Import DB Schema form ODBC…
  3. Select the Database Name / ODBC
  4. Set a Schema/Owner
  5. Press Import
  6. Select the tables to import and press OK

tada… done… easy as hell, as soon as the odbc works :/

and really cool is the generate DDL function compare… when generating DDL, press the compare button and set the odbc… and view… so it shows you all the changes, and suggested actions… how to extract these, is some thing different :/ something for my next post 🙂

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: database model: create index

and enterprise architect can add indexes… just right-click on the table and select operations… und create the index… its a bit fency, because you need to create it, then select it, then tab to Column, and then you can select the columns, which need to be indexed… its confusing, because you select something on one tab, and then select other things on other tabs…

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…

database modeling with enterprise architect

so finally got an Spary Enterprise Architect 🙂 the “:)” is kinda relative, because i really dont care, which program i should use for modeling tables and creating ddl’s… but the project said: use ea… and so i did… installing software in a really big company (as i am working now) can be really a pain… but after a few days, i got it up and runing… finally… so its kinda “:)”

and i think its really good… had a few problems in the beginning, created a table and colums, but couldn’t set columntypes, but master this problem… the table needs to know, which database it is in… kinda clear, but i thought the definition should be somewhere on the project or on the schema… not directly on the table…

so currently “painting” my model 🙂