I am trying to get Doctrine2 Entities, ordered by their ID which apparently is a String even though it contains only Numbers.
So what I would like to do is something like this:

SELECT entity1, cast (entity1.id AS integer) AS orderId
FROM Namespace\Bla\MyEntity 
ORDER BY orderId


Is there a way to do something like this in Doctrine2?
Or, what would be the best practise to get my Result if i can't change the type of the id (due to customer requirements of course)?



Attention: I am not asking SQL Code, i am asking for a Doctrine2 Solution, preferably in DQL


Question: How do I make a query for if value exists in row add a value to another field?
Answer: You could do this:

         update yourTable
         set yourFinalColumnWhateverItsNameIs = {your desired value}
         where someColumn = 3


Every row in the table that has a 3 in the someColumn column will then have that final column set to your desired value. 

If this isn't what you want, please make your question clearer.  Are you trying to put the name of the hospital into this table? If so, that is not a good idea and there are better ways to accomplish that.

Furthermore, if every row with a certain value (3) gets this value, you could simply add it to the other (i.e. Hospitals) table. No need to repeat it everywhere in the table that points back to the Hospitals table.

P.S. Here's an example of what I meant:

Let's say you have two tables

HOSPITALS
id
name
city
state

BIRTHS
id
hospitalid
babysname
gender
mothersname
fathername


You could get a baby's city of birth without having to include the City column in the Births table, simply by joining the tables on hospitals.id = births.hospitalid.