Carlos,
If you don't use DB specific SQL, it is portable. This is true regardless of technology (pure
JDBC,
EJB, Hibernate, etc.) It is also possible to write non-portable code using any technology. For example native queries in JPA.
Note that EJB 3 is JPA for the entity beans part. And Hibernate is an implementation of JPA.