You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Francois Eyl <fe...@smaeur.eu> on 2011/10/14 14:27:33 UTC

Best practice to support multiple database vendors (DB2 or MSSQL Server)

Hi guys,

I'm using Cayenne on my project in order to interface it with a third 
party application through its database. Until now, the database was a 
DB2 (AS400), but the application now supports MS SQL Server as well. So, 
I need to support both DB2 and MSSQL Server of course. The databases 
schemas are stricly the same.

I wonder what is the best way to achieve this, knowing that I already 
have my datamap & datanode ready for DB2. I'd like to avoid redefining 
ObjectEntities by implementation (one set of data for DB2 and another 
for SQLServer). How do you recommand me to proceed?

Do I need to create an other DataDomain, and "duplicate" the definition 
stuff?

Thanks in advance,
Francois


Re: [OT] You're all a bunch of Cake Mixers

Posted by Malcolm Edgar <ma...@gmail.com>.
I love it,that annotation slide was beautiful.

regards Malcolm

On Wed, Oct 19, 2011 at 9:04 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> Hey, Cayenne Developers! Stop destroying our joy of programming!
>
> http://vimeo.com/28885655
>
> - hugi
>
> PS: Sorry for the off topic post, couldn't resist…

Re: [OT] You're all a bunch of Cake Mixers

Posted by Joe Baldwin <jf...@earthlink.net>.
Check out this link on the Toaster Project

	http://www.thetoasterproject.org/

BTW, if you are unfamiliar with the project - a graduate student decided to build a toaster, but without the use of any pre-made materials of *any* kind (well except book libraries I am presuming). 

Gorman's fascination with understanding infrastructure components is a stage many advanced programmers go through. It is a wonder that she actually took this idea seriously.



On Oct 19, 2011, at 6:04 AM, Hugi Thordarson wrote:

> Hey, Cayenne Developers! Stop destroying our joy of programming!
> 
> http://vimeo.com/28885655
> 
> - hugi
> 
> PS: Sorry for the off topic post, couldn't resist…


Re: [OT] You're all a bunch of Cake Mixers

Posted by Marek Šabo <ms...@buk.cvut.cz>.
"bloating apps with generic junk" -> well when you work on your own 
projects maybe but when customer changes his mind twice a week, generic 
junks starts becoming quite handy.

On 10/19/2011 12:54 PM, Bruno René Santos wrote:
> Hey Hugi,
>
> Continuing the off-topic :) (sorry everyone feel free to ignore this) I have
> just watched the clip and yet she has a point I think It is totally
> dependent on the amount of logic your project has and also the the
> frameworks you're using. For large projects and large teams, worrying about
> CSS, HTML, SQL and other low level conceptions on a daily basis can be quite
> a nuisance when you have forms and windows layouts with dozens of fields
> that need validation, event handling and persistence. I use cayenne for most
> of my projects and I dont feel cheated or disconnected from the low levels
> of my application at all, but being able to worry with more high-level
> concepts on a daily basis it is much more efficient, at least for me.
I completely agree.

Marek.

Re: [OT] You're all a bunch of Cake Mixers

Posted by Hugi Thordarson <hu...@karlmenn.is>.
I agree with every word. She tried to eat soup with a fork, and decided soup can't be eaten with tools.

It's sad that most people's exposure to ORMs is limited to Hibernate and JPA, leading them to draw negative conclusions about the entire technology. We have a large responsibility; to introduce the world to a usable ORM :).

Cheers,
- hugi


On 19.10.2011, at 10:54, Bruno René Santos wrote:

> Hey Hugi,
> 
> Continuing the off-topic :) (sorry everyone feel free to ignore this) I have
> just watched the clip and yet she has a point I think It is totally
> dependent on the amount of logic your project has and also the the
> frameworks you're using. For large projects and large teams, worrying about
> CSS, HTML, SQL and other low level conceptions on a daily basis can be quite
> a nuisance when you have forms and windows layouts with dozens of fields
> that need validation, event handling and persistence. I use cayenne for most
> of my projects and I dont feel cheated or disconnected from the low levels
> of my application at all, but being able to worry with more high-level
> concepts on a daily basis it is much more efficient, at least for me.
> 
> Comparing Bakers with Programmers is also somewhat problematic because some
> of the best qualities of programmers are not quite good for bakers. For
> example lazyness. A good programmer is lazy. We dont want to repeat code all
> the time, we dont like to write a lot of code and so we try to find ways to
> encapsulate parts of our applications and also find tools that help us do
> more doing less (nice concept :)).
> 
> At the clip, in my opinion she used the worst example possible, hibernate.
> When I was analyzing ORMs, as most people, I tried to find those pages with
> titles like "The Top Ten Things that do this" for ORMs and of course
> Hibernate was the first on most lists. But when I tried the learn it or even
> use it on a small example I was amazed the amount of documentation and work
> you have to do prior to having something working (my lazy side kicked in -
> any framework that take me more than a day to do something reasonable is
> kinda on the bottom of my list...). And also the amount of programmers
> complaining about hibernate was quite large.
> 
> During that time I came across Cayenne and thank god I found it! It took me
> no time to use it, the documentation was proper (could be a more organized
> but it wasn't a showstopper) and the DataContext was the thing that made
> decide for it. I know I am preaching on the same 'church' but even so, for
> me, it is the first feature that smashes hibernate to the ground. Come on,
> calling .save() for each object and being worried about in what order you do
> it is just too much work (I know this is JPA fault but even so...).
> 
> Coming back to the clip, I think tools like Cayenne are those mixes that
> chefs use, like I saw so many times on cooking shows where a chef uses
> this ingredient and says : "You can get this also fresh but this one is
> cheaper, you can get it faster on the supermarket and tastes as good as the
> fresh product". So no shame on taking some shortcuts as long as the final
> product was cheaper, faster to make and the end user (or eater) is satisfied
> with it.
> 
> The real message here should be: chose what you think will help you more and
> not what everyone is using it just because (some top manager told you to use
> it because all CV's ask for it).
> 
> Regards and sorry again for the off-topic
> Bruno
> 
> On Wed, Oct 19, 2011 at 11:04 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
>> Hey, Cayenne Developers! Stop destroying our joy of programming!
>> 
>> http://vimeo.com/28885655
>> 
>> - hugi
>> 
>> PS: Sorry for the off topic post, couldn't resist…
>> 
> 
> 
> 
> -- 
> Bruno René Santos | brunorene@holos.pt | Gestor de Projectos | Analista |
> Programador | Investigador
> 
> Holos - Soluções Avançadas em Tecnologias de Informação S.A.
> Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan Parque
> Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
> Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt
> 
> This email and any files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they are addressed.
> If you are not the intended recipient or the person responsible for
> delivering the email to the intended recipient, be advised that you have
> received this email in error and that any use, dissemination, forwarding,
> printing, or copying of this email is strictly prohibited. If you have
> received this email in error please notify Bruno René Santos by telephone on
> +351 210 438 686


Re: [OT] You're all a bunch of Cake Mixers

Posted by Bruno René Santos <br...@holos.pt>.
Hey Michael,

Sorry I did not know that. Well then the fault is all on Hibernate. Shame on
it!

Regards
Bruno

On Wed, Oct 19, 2011 at 3:09 PM, Michael Gentry <mg...@masslight.net>wrote:

> Technically, I believe Hibernate influenced JPA, not the other way around.
>
> mrg
>
>
> On Wed, Oct 19, 2011 at 6:54 AM, Bruno René Santos <br...@holos.pt>
> wrote:
> > Come on,
> > calling .save() for each object and being worried about in what order you
> do
> > it is just too much work (I know this is JPA fault but even so...).
>
>


-- 
Bruno René Santos | brunorene@holos.pt | Gestor de Projectos | Analista |
Programador | Investigador

Holos - Soluções Avançadas em Tecnologias de Informação S.A.
Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan Parque
Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you are not the intended recipient or the person responsible for
delivering the email to the intended recipient, be advised that you have
received this email in error and that any use, dissemination, forwarding,
printing, or copying of this email is strictly prohibited. If you have
received this email in error please notify Bruno René Santos by telephone on
+351 210 438 686

Re: [OT] You're all a bunch of Cake Mixers

Posted by Michael Gentry <mg...@masslight.net>.
Technically, I believe Hibernate influenced JPA, not the other way around.

mrg


On Wed, Oct 19, 2011 at 6:54 AM, Bruno René Santos <br...@holos.pt> wrote:
> Come on,
> calling .save() for each object and being worried about in what order you do
> it is just too much work (I know this is JPA fault but even so...).

Re: [OT] You're all a bunch of Cake Mixers

Posted by Bruno René Santos <br...@holos.pt>.
Hey Hugi,

Continuing the off-topic :) (sorry everyone feel free to ignore this) I have
just watched the clip and yet she has a point I think It is totally
dependent on the amount of logic your project has and also the the
frameworks you're using. For large projects and large teams, worrying about
CSS, HTML, SQL and other low level conceptions on a daily basis can be quite
a nuisance when you have forms and windows layouts with dozens of fields
that need validation, event handling and persistence. I use cayenne for most
of my projects and I dont feel cheated or disconnected from the low levels
of my application at all, but being able to worry with more high-level
concepts on a daily basis it is much more efficient, at least for me.

Comparing Bakers with Programmers is also somewhat problematic because some
of the best qualities of programmers are not quite good for bakers. For
example lazyness. A good programmer is lazy. We dont want to repeat code all
the time, we dont like to write a lot of code and so we try to find ways to
encapsulate parts of our applications and also find tools that help us do
more doing less (nice concept :)).

At the clip, in my opinion she used the worst example possible, hibernate.
When I was analyzing ORMs, as most people, I tried to find those pages with
titles like "The Top Ten Things that do this" for ORMs and of course
Hibernate was the first on most lists. But when I tried the learn it or even
use it on a small example I was amazed the amount of documentation and work
you have to do prior to having something working (my lazy side kicked in -
any framework that take me more than a day to do something reasonable is
kinda on the bottom of my list...). And also the amount of programmers
complaining about hibernate was quite large.

During that time I came across Cayenne and thank god I found it! It took me
no time to use it, the documentation was proper (could be a more organized
but it wasn't a showstopper) and the DataContext was the thing that made
decide for it. I know I am preaching on the same 'church' but even so, for
me, it is the first feature that smashes hibernate to the ground. Come on,
calling .save() for each object and being worried about in what order you do
it is just too much work (I know this is JPA fault but even so...).

Coming back to the clip, I think tools like Cayenne are those mixes that
chefs use, like I saw so many times on cooking shows where a chef uses
this ingredient and says : "You can get this also fresh but this one is
cheaper, you can get it faster on the supermarket and tastes as good as the
fresh product". So no shame on taking some shortcuts as long as the final
product was cheaper, faster to make and the end user (or eater) is satisfied
with it.

The real message here should be: chose what you think will help you more and
not what everyone is using it just because (some top manager told you to use
it because all CV's ask for it).

Regards and sorry again for the off-topic
Bruno

On Wed, Oct 19, 2011 at 11:04 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:

> Hey, Cayenne Developers! Stop destroying our joy of programming!
>
> http://vimeo.com/28885655
>
> - hugi
>
> PS: Sorry for the off topic post, couldn't resist…
>



-- 
Bruno René Santos | brunorene@holos.pt | Gestor de Projectos | Analista |
Programador | Investigador

Holos - Soluções Avançadas em Tecnologias de Informação S.A.
Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan Parque
Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you are not the intended recipient or the person responsible for
delivering the email to the intended recipient, be advised that you have
received this email in error and that any use, dissemination, forwarding,
printing, or copying of this email is strictly prohibited. If you have
received this email in error please notify Bruno René Santos by telephone on
+351 210 438 686

[OT] You're all a bunch of Cake Mixers

Posted by Hugi Thordarson <hu...@karlmenn.is>.
Hey, Cayenne Developers! Stop destroying our joy of programming!

http://vimeo.com/28885655

- hugi

PS: Sorry for the off topic post, couldn't resist…

Re: Best practice to support multiple database vendors (DB2 or MSSQL Server)

Posted by John Huss <jo...@gmail.com>.
>
> As for ongoing maintenance (upgrading the database, running scripts, etc)
> I've recently discovered liquibase and it is really rather nice for dealing
> with different databases without rewriting lots of SQL by hand.
>

I'm working on a migrations API for Cayenne to do this.  It's actually done,
I just need to write the unit tests.  I hoping to contribute it.  It
provides an API for creating changing the DB schema over time and uses the
MergerFactory and MergerTokens along with the DbAdapter to do the work.

John

Re: Best practice to support multiple database vendors (DB2 or MSSQL Server)

Posted by Aristedes Maniatis <ar...@maniatis.org>.
On Sat Oct 15 11:21:59 2011, Aristedes Maniatis wrote:
> On Sat Oct 15 00:11:26 2011, Francois Eyl wrote:
>> Ok, that's what I was wondering, but wasn't sure because of all DBEntity attributes that seem to be specific to database's vendor (CHAR vs NCHAR or DECIMAL vs NUMERIC).
>>
>> I'll try to connect to the MSSQL database using the appropriate JDBC driver and see.
>>
>> Thanks,
>> Francois
>>
>> On 14/10/2011 14:39, Aristedes Maniatis wrote:
>>> On Fri Oct 14 23:27:33 2011, Francois Eyl wrote:
>>>> Hi guys,
>>>>
>>>> I'm using Cayenne on my project in order to interface it with a third party application through its database. Until now, the database was a DB2 (AS400), but the application now supports MS SQL Server as well. So, I need to support both DB2 and MSSQL Server of course. The databases schemas are stricly the same.
>>>>
>>>> I wonder what is the best way to achieve this, knowing that I already have my datamap & datanode ready for DB2. I'd like to avoid redefining ObjectEntities by implementation (one set of data for DB2 and another for SQLServer). How do you recommand me to proceed?
>>>>
>>>> Do I need to create an other DataDomain, and "duplicate" the definition stuff?
>>>>
>>>> Thanks in advance,
>>>> Francois
>>>>
>>>
>>> In most cases, there is absolutely nothing to do at all. Just connect to the database of your choice and Cayenne will make it all work.
>>>
>
> They are the JDBC data types, not the SQL equivalents (often with the same name, but not always).
>
>

Sorry, pressed send too quickly....

The best reference I've found is this one:

  
http://download.oracle.com/javase/1.3/docs/guide/jdbc/getstart/mapping.html

The main issues that I've found between databases have been around 
collation (case insensitive / sensitive makes a big difference to your 
queries). Timezones (for example mysql never stores them but defaults 
to a system timezone for the whole server). Indexing (eg. some 
databases let you have functional indices and others don't).

As for ongoing maintenance (upgrading the database, running scripts, 
etc) I've recently discovered liquibase and it is really rather nice 
for dealing with different databases without rewriting lots of SQL by 
hand.

Ari

-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Re: Best practice to support multiple database vendors (DB2 or MSSQL Server)

Posted by Aristedes Maniatis <ar...@maniatis.org>.
On Sat Oct 15 00:11:26 2011, Francois Eyl wrote:
> Ok, that's what I was wondering, but wasn't sure because of all DBEntity attributes that seem to be specific to database's vendor (CHAR vs NCHAR or DECIMAL vs NUMERIC).
>
> I'll try to connect to the MSSQL database using the appropriate JDBC driver and see.
>
> Thanks,
> Francois
>
> On 14/10/2011 14:39, Aristedes Maniatis wrote:
>> On Fri Oct 14 23:27:33 2011, Francois Eyl wrote:
>>> Hi guys,
>>>
>>> I'm using Cayenne on my project in order to interface it with a third party application through its database. Until now, the database was a DB2 (AS400), but the application now supports MS SQL Server as well. So, I need to support both DB2 and MSSQL Server of course. The databases schemas are stricly the same.
>>>
>>> I wonder what is the best way to achieve this, knowing that I already have my datamap & datanode ready for DB2. I'd like to avoid redefining ObjectEntities by implementation (one set of data for DB2 and another for SQLServer). How do you recommand me to proceed?
>>>
>>> Do I need to create an other DataDomain, and "duplicate" the definition stuff?
>>>
>>> Thanks in advance,
>>> Francois
>>>
>>
>> In most cases, there is absolutely nothing to do at all. Just connect to the database of your choice and Cayenne will make it all work.
>>

They are the JDBC data types, not the SQL equivalents (often with the 
same name, but not always).


-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Re: Best practice to support multiple database vendors (DB2 or MSSQL Server)

Posted by Francois Eyl <fe...@smaeur.eu>.
Ok, that's what I was wondering, but wasn't sure because of all DBEntity 
attributes that seem to be specific to database's vendor (CHAR vs NCHAR 
or DECIMAL vs NUMERIC).

I'll try to connect to the MSSQL database using the appropriate JDBC 
driver and see.

Thanks,
Francois

On 14/10/2011 14:39, Aristedes Maniatis wrote:
> On Fri Oct 14 23:27:33 2011, Francois Eyl wrote:
>> Hi guys,
>>
>> I'm using Cayenne on my project in order to interface it with a third 
>> party application through its database. Until now, the database was a 
>> DB2 (AS400), but the application now supports MS SQL Server as well. 
>> So, I need to support both DB2 and MSSQL Server of course. The 
>> databases schemas are stricly the same.
>>
>> I wonder what is the best way to achieve this, knowing that I already 
>> have my datamap & datanode ready for DB2. I'd like to avoid 
>> redefining ObjectEntities by implementation (one set of data for DB2 
>> and another for SQLServer). How do you recommand me to proceed?
>>
>> Do I need to create an other DataDomain, and "duplicate" the 
>> definition stuff?
>>
>> Thanks in advance,
>> Francois
>>
>
> In most cases, there is absolutely nothing to do at all. Just connect 
> to the database of your choice and Cayenne will make it all work.
>

Re: Best practice to support multiple database vendors (DB2 or MSSQL Server)

Posted by Aristedes Maniatis <ar...@maniatis.org>.
On Fri Oct 14 23:27:33 2011, Francois Eyl wrote:
> Hi guys,
>
> I'm using Cayenne on my project in order to interface it with a third party application through its database. Until now, the database was a DB2 (AS400), but the application now supports MS SQL Server as well. So, I need to support both DB2 and MSSQL Server of course. The databases schemas are stricly the same.
>
> I wonder what is the best way to achieve this, knowing that I already have my datamap & datanode ready for DB2. I'd like to avoid redefining ObjectEntities by implementation (one set of data for DB2 and another for SQLServer). How do you recommand me to proceed?
>
> Do I need to create an other DataDomain, and "duplicate" the definition stuff?
>
> Thanks in advance,
> Francois
>

In most cases, there is absolutely nothing to do at all. Just connect 
to the database of your choice and Cayenne will make it all work.

-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A