-
1. Weired JPA named query @NamedQuery behaviour
ilya40umov Jan 24, 2011 4:41 AM (in response to thegroove)I guess that it's ok because when you are using annotations and named queries there is not need to generate something. Named queries in annotations are completely fixed and static and they are supposed to be read only once by Jboss. If you really want to generate where expression you can always use EntityManager.createQuery.
see
http://download.oracle.com/javaee/5/api/javax/persistence/EntityManager.html
Actually I have never tried to generate where expressions for namedQueries because they should have been created before an application is deployed to an application server.
-
2. Weired JPA named query @NamedQuery behaviour
thegroove Jan 24, 2011 5:48 AM (in response to ilya40umov)Salut Ilya,
i understoot your argumentation, but i believe (definitivly not sure)
this shall not be correct, because JAVA does not know anymodifier
called "completly fixed and static".
You may assign the annoation a final static String attribute, that is
composed of other String using concenation using the +-operator.
There is no reason, why +-operator works but a static method not!
-
3. Weired JPA named query @NamedQuery behaviour
ilya40umov Jan 24, 2011 6:18 AM (in response to thegroove)IMHO Because a static field(like "a" + "b") is calculated when java code is compiled but a static function is a runtime thing. So that Jboss may read this annotations before this functions is run.
-
4. Weired JPA named query @NamedQuery behaviour
thegroove Jan 24, 2011 6:44 AM (in response to ilya40umov)Salut Ilya,
iff your +-composition resides in another class, then you
habe a class-loader job between. And then ???
-
5. Weired JPA named query @NamedQuery behaviour
ilya40umov Jan 24, 2011 7:00 AM (in response to thegroove)I still think that "a class-loader job" does not mean executing any javacode.
http://www.objectdb.com/java/jpa/query/named
A named query is a statically defined query with a predefined unchangeable query string.
if you have a static function it means that you can change a query through changing this function. The logic of the function lies in runtime level and you can change it by changing some function parameters. I suppose that Jboss/Hibernate reads all the annotations before you static code is executed.
P.S. I think that someone else can describe it more clearly. And what I'm saying is just my own opinion. And I'm sure that everyone can be mistaken.
-
6. Weired JPA named query @NamedQuery behaviour
thegroove Jan 24, 2011 3:20 PM (in response to ilya40umov)Salut Ilja,
> A named query is a statically defined query with a predefined unchangeable query string.
i agree to this, bit Dbean1.JPQL_COMPOSITION is definitivly static and
unachnageable. For that reason i use final-static modifier. But
Jboss still think, it is not.
but:
@NamedQueries(
{
@NamedQuery(
name=Dbean1.GET_COMPOSITION,
query=Dbean1.JPQL_COMPOSITION)
}
)
where:
@Entity
public class Dbean1. implements Serializable
{
/* some code */
final public static String GET_COMPOSITION = ".... composition " ;
final public static String JPQL_COMPOSITION = "SELECT dbean FROM ..... " + Dbean1.dummyClass() ;