Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Update statement is no query?

How do I define the update statement in the orm.xml. I have it as a named-query and everything works, but my teacher said that an update statement isn’t a query. I have tried a native query, but that wasn’t working.

ORM-Type:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="1.0"
    xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd">

Update Statement:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<named-query name="updateTshirts">
    <query>
        update Tshirt tshirt Set tshirt.bEdit = :bedit, tshirt.farbe = :farbe,
        tshirt.groesse = :groesse, tshirt.markenName = :markenname where
        tshirt.tID = :tid
    </query>
</named-query>

>Solution :

The term "query" is used rather ambiguously. Some people interpret it literally as "asking for information", meaning only select statements or other things producing a result set fall under this term, while others interpret it more broadly as any DML (Data Manipulation Language, i.e. select, insert, update, delete, merge, etc) statement.

Your teacher seems to fall in the first category, while the people who created the Jakarta Persistence API (JPA) fall into the second category. So, in a sense you’re both right, in the first interpretation, an update statement is not a "query", but in the second interpretation, which is used by JPA, it is a "query".

However, given the context, your interpretation is the better one.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading