I am developing a spring boot app with hibernate an liquibase on a postsgre db. When i start the spring boot app, the changelog is updated in the db and the log says, that the script run successfully, but the table is still in the schema.
This is my db.changelog.xml:
<changeSet author="stimpson" id="deletetablehans">
<sqlFile dbms="postgre" encoding="UTF-8" endDelimiter=";"
path="sql/00003_deleteTableHans.sql" relativeToChangelogFile="true"
splitStatements="true" stripComments="true" />
</changeSet>
This is my script (deletetablehans.sql in the sql folder):
--liquibase formatted sql
--changeset stimpson:deleteTableHans
DROP TABLE HANS;
commit;
;
This is part of my logfile:
2021-01-25 15:43:50,438 INFO liquibase.lockservice : Changelog-Protokoll erfolgreich gesperrt.
2021-01-25 15:43:50,686 INFO liquibase.changelog : Reading from public.databasechangelog
2021-01-25 15:43:50,704 INFO liquibase.changelog : ChangeSet db/dbchangelog.xml::deletetablehans::stimpson ran successfully in 0ms
2021-01-25 15:43:50,709 INFO liquibase.lockservice : Successfully released change log lock
I do not care why the language changes, but when i look at the database, I see that the table named Hans is still there. But why? I did try with an explicit commit and the delimiter in its own line, but i do not understand the outcome?
This is my liquibase.properties file:
changeLogFile=src/main/resources/db/dbchangelog.xml
url=jdbc:postgresql://localhost:5432/padsyhw3
username=dbuser
password=dbpass
driver=org.postgresql.Driver
This is the only data row in the databasechangelog table in DB:
deletetablehans stimpson db/dbchangelog.xml 2021-01-25 15:49:05 1 EXECUTED 8:90e2fa99c6beeace580e429bd2bf9ae3 sqlFile 4.2.2
I have a working solution to your problem
I wonder if the case difference between deletetablehans and deleteTableHans could have an impact on the execution of the changeset
According to the liquibase supported databases, when using dbms for postgre you should use the value postgresql while you used postgre
Do you have any specific reason to use a changeset inside of an SQL file to do the drop action ? I can see at least two alternatives if no one can bring you a valid solution
Alternative 1: Use sql instead of sqlFile
<changeSet author="stimpson" id="deletetablehans">
<sql dbms="postgresql">
DROP TABLE HANS;
</sql>
</changeSet>
Alternative 2: Use liquibase dropTable
<changeSet author="stimpson" id="deletetablehans">
<dropTable tableName="HANS" />
</changeSet>
Related
We are facing a serious problem with H2 database, version 1.4.199 - server mode. The application data layer creates a table programmatically if not exists, for example:
CREATE TABLE IF NOT EXISTS mytable (...);
CREATE INDEX IF NOT EXISTS idx_mytable ON mytable(mycol);
and works fine for days, writing data into the above table. After restarting the service, at first connection attempt, the engine throws the error
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "mytable" not found; SQL statement:
CREATE INDEX "PUBLIC"."IDX_MYTABLE" ON "PUBLIC"."MYTABLE"("MYCOL")
If we try recovering the database, the sql script does not contain the "mytable" anymore, so the data are definitevely lost! We have hundreds of installations of the software, but the error happens occasionally on some of them (10%).
Ping us H2 properties which you used.
"spring.jpa.hibernate.ddl-auto" should be "update".
I am using MyBatis for developing my application . Now i have stumbled upon a situation where the sql query should return last inserted id to me ,
I am using MySql for development and H2 DB for Integration Testing .
In MySql we use last_insert_id() function to get this id but in H2 DB we use currval() functiton . Even if i use sequence in MySql still this syntax would be different .
The question now is how am i suppose to write integration testing code . Since same query what i have written for the development is used for integration testing . what i should do in this kind of situation
You can use dynamic SQL, based on either database type, or maybe other variable that you have available (e.g. an environment variable with the current profile).
An example from the documentation:
<insert id="insert">
<selectKey keyProperty="id" resultType="int" order="BEFORE">
<if test="_databaseId == 'oracle'">
select seq_users.nextval from dual
</if>
<if test="_databaseId == 'db2'">
select nextval for seq_users from sysibm.sysdummy1"
</if>
</selectKey>
insert into users values (#{id}, #{name})
</insert>
Refer to the documentation here.
If you're using Spring boot, you can try to put the below property in your test application.properties file. Just one line:
spring.datasource.url=jdbc:h2:mem:test;MODE=MySQL
The keyword is MODE=MySQL, and it works for me.
I am trying to use hsqldb-2.3.4 to connect from Spring applicastion.
I created data base using the following details
Type : HSQL Database Engine Standalone
Driver: org.hsqldb.jdbcDriver
URL: jdbc:hsqldb:file:mydb
UserName: SA
Password: SA
I created a table named ALBUM under "MYDB" schema
In spring configuration file:
<bean id="jdbcTemplate"
class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
<constructor-arg ref="dbcpDataSource" />
</bean>
<bean id="dbcpDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:file:mydb" />
<property name="username" value="SA" />
<property name="password" value="SA" />
</bean>
And in my spring controller I am doing jdbcTemplate.query("SELECT * FROM MYDB.ALBUM", new AlbumRowMapper());
And It gives me exception:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT * FROM MYDB.ALBUM]; nested exception is java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: ALBUM
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
If I execute same query through SQL editor of hsqldb it executes fine. Can you please help me with this.
As said by a previous response there is many possible causes. One of them is that the table isn't created because of syntax incompatibility. If specific DB vendor syntax or specific capability is used, HSQLDB will not recognize it. Then while the creation code is executed you could see that the table is not created for this syntax reason. For exemple if the entity is annoted with #Column(columnDefinition = "TEXT") the creation of the table will fail.
There is a work around which tell to HSQLDB to be in a compatible mode
for pgsl you should append your connection url with that
"spring.datasource.url=jdbc:hsqldb:mem:testdb;sql.syntax_pgs=true"
and for mysql with
"spring.datasource.url=jdbc:hsqldb:mem:testdb;sql.syntax_mys=true"
oracle
"spring.datasource.url=jdbc:hsqldb:mem:testdb;sql.syntax_ora=true"
note there is variant depending on your configuration
it could be hibernate.connection.url= or spring.datasource.url=
for those who don't use the hibernate schema creation but a SQL script you should use this kind of syntax in your script
SET DATABASE SQL SYNTAX ORA TRUE;
It will also fix issues due to vendor specific syntax in SQL request such as array_agg for posgresql
Nota bene : The the problem occurs very early when the code parse the model to create the schema and then is hidden in many lines of logs, then the unitTested code crash with a confusing and obscure exception "user lacks privilege or object not found error" which does not point the real problem at all. So make sure to read all the trace from the beginning and fix all possible issues
If you've tried all the other answers on this question, then it is most likely that you are facing a case-sensitivity issue.
HSQLDB is case-sensitive by default. If you don't specify the double quotes around the name of a schema or column or table, then it will by default convert that to uppercase. If your object has been created in uppercase, then you are in luck. If it is in lowercase, then you will have to surround your object name with double quotes.
For example:
CREATE MEMORY TABLE "t1"("product_id" INTEGER NOT NULL)
To select from this table you will have to use the following query
select "product_id" from "t1"
user lacks privilege or object not found can have multiple causes, the most obvious being you're accessing a table that does not exist. A less evident reason is that, when you run your code, the connection to a file database URL actually can create a DB. The scenario you're experiencing might be you've set up a DB using HSQL Database Manager, added tables and rows, but it's not this specific instance your Java code is using. You may want to check that you don't have multiple copies of these files: mydb.log, mydb.lck, mydb.properties, etc in your workspace. In the case your Java code did create those files, the location depends on how you run your program. In a Maven project run inside Netbeans for example, the files are stored alongside the pom.xml.
I had the error user lacks privilege or object not found while trying to create a table in an empty in-memory database.
I used spring.datasource.schema and the problem was that I missed a semicolon in my SQL file after the "CREATE TABLE"-Statement (which was followed by "CREATE INDEX").
I had similar issue with the error 'org.hsqldb.HsqlException: user lacks privilege or object not found: DAYS_BETWEEN' turned out DAYS_BETWEEN is not recognized by hsqldb as a function. use DATEDIFF instead.
DATEDIFF ( <datetime value expr 1>, <datetime value expr 2> )
When running a HSWLDB server. for example your java config file has:
hsql.jdbc.url = jdbc:hsqldb:hsql://localhost:9005/YOURDB;sql.enforce_strict_size=true;hsqldb.tx=mvcc
check to make sure that your set a server.dbname.#. for example my server.properties file:
server.database.0=eventsdb
server.dbname.0=eventsdb
server.port=9005
I was inserting the data in hsql db using following script
INSERT INTO Greeting (text) VALUES ("Hello World");
I was getting issue related to the Hello World object not found and HSQL database user lacks privilege or object not found error
which I changed into the below script
INSERT INTO Greeting (text) VALUES ('Hello World');
And now it is working fine.
Add these two extra properties:
spring.jpa.hibernate.naming.implicit-strategy=
org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
spring.jpa.hibernate.naming.physical-strategy=
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
I bumped into kind of the same problem recently. We are running a grails application and someone inserted a SQL script into the BootStrap file (that's the entry point for grails). That script was supposed to be run only in the production environment, however because of bad logic it was running in test as well. So the error I got was:
User lacks privilege or object not found:
without any more clarification...
I just had to make sure the script was not run in the test environment and it fixed the problem for me, though it took me 3 hours to figure it out. I know it is very, very specific issue but still if I can save someone a couple of hours of code digging that would be great.
I was having the same mistake. In my case I was forgetting to put the apas in the strings.
I was doing String test = "inputTest";
The correct one is String test = "'inputTest'";
The error was occurring when I was trying to put something in the database
connection.createStatement.execute("INSERT INTO tableTest values(" + test +")";
In my case, just put the quotation marks ' to correct the error.
In my case the error occured because i did NOT put the TABLE_NAME into double quotes "TABLE_NAME" and had the oracle schema prefix.
Not working:
SELECT * FROM FOOSCHEMA.BAR_TABLE
Working:
SELECT * FROM "BAR_TABLE"
had this issue with concatenating variables in insert statement. this worked
// var1, var3, var4 are String variables
// var2 and var5 are Integer variables
result = statement.executeUpdate("INSERT INTO newTable VALUES ('"+var1+"',"+var2+",'"+var3+"','"+var4+"',"+var5 +")");
In my case the issue was caused by the absence (I'd commented it out by mistake) of the following line in persistence.xml:
<property name="hibernate.hbm2ddl.auto" value="update"/>
which prevented Hibernate from emitting the DDL to create the required schema elements...
(different Hibernate wrappers will have different mechanisms to specify properties; I'm using JPA here)
I had this error while trying to run my application without specifying the "Path" field in Intellij IDEA data source (database) properties. Everything else was configured correctly.
I was able to run scripts in IDEA database console and they executed correctly, but without giving a path to the IDEA, it was unable to identify where to connect, which caused errors.
You have to run the Database in server mode and connect.Otherwise it wont connect from external application and give error similar to user lacks privilege.
Also change the url of database in spring configuration file accordingly when running DB in server mode.
Sample command to run DB in server mode
$java -cp lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:data/mydb --dbname.0 Test
Format of URL in configuration file
jdbc:hsqldb:hsql://localhost/Test
In my case, one of the columns had the name 'key' with the missing #Column(name = "key") annotation so that in the logs you could see the query that created the table but in fact it was not there. So be careful with column names
For what it's worth - I had this same problem. I had a column named 'TYPE', which I renamed to 'XTYPE' and a column named ORDER which I renamed to 'XORDER' and the problem went away.
Yet another reason could be a misspelt field name. If your actual table has an id column named albumid and you'd used album_id, then too this could occur.
As another anwer remarked, case differences in field names too need to be taken care of.
I faced the same issue and found there was more than one PersistenceUnit (ReadOnly and ReadWrite) , So the tables in HSQLDDB created using a schema from one persistence unit resulted in exception(HSQL database user lacks privilege or object not found error) being thrown when accessed from other persistence unit .It happens when tables are created from one session in JPA and accessed from another session
In my case the table MY_TABLE was in the schema SOME_SCHEMA. So calling select/insert etc. directly didn't work. To fix:
add file schema.sql to the resources folder
in this file add the line CREATE SCHEMA YOUR_SCHEMA_NAME;
I'm currently building a project for my internship, and I'm stuck since two days trying to use Liquibase in java. Everything seems right : the changelog file is found, correct URI, username and password; but when I run it, my changesets are not processed.
I use this class to manage liquibase actions from my program, such as rollback, update, updateSQL and futureRollbackSQL, given a changelog and eventually a destination file. If the source or destination is from a remote server, I use some SSH interactions (scp to, scp from) with JSch and temporary files (but it's not the topic).
This is the java code I have for now, given db, user, passwd, realAction are set previously, changelogpath and dest are some data storage class.
Connection c = null;
Database database = null;
PrintWriter pw = null;
File file = null;
liquibase.Liquibase liquibase = null;
contexts = db+"."+user;
try {
pw = new PrintWriter(new FileWriter(file));
// Get connection
c = SQLManager.getInstance().getConnection(db, user, passwd);
// Get liquibase connection
database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(c));
liquibase = new liquibase.Liquibase(new DatabaseChangeLog(fsource), new FileSystemResourceAccessor(),
database);
// Run liquibase action
switch (realAction) {
case Constants.LIQUIBASE_ACTION_FUTUREROLLBACKSQL:
liquibase.futureRollbackSQL(pw);
break;
case Constants.LIQUIBASE_ACTION_UPDATESQL:
liquibase.update(contexts, pw);
break;
case Constants.LIQUIBASE_ACTION_UPDATE:
liquibase.update(contexts);
if (!c.getAutoCommit())
c.commit();
break;
default:
throw new OdewipElementRuntimeException(this, "Action not implemented");
}
pw.close();
database.close();
c.close();
} catch (IOException | SQLException | LiquibaseException e) {
throw new Exception(e.getMessage());
} finally {
if (c != null) {
try {
c.close();
} catch (SQLException e) {
// nothing to do
throw new RuntimeException(e.getClass() + ": " + e.getMessage());
}
}
}
And here is my changelog:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ora="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="mychangeset" author="testy">
<preConditions onSqlOutput="TEST" onFail="MARK_RAN">
<not>
<tableExists tableName="abcd"/>
</not>
</preConditions>
<createTable tableName="abcd">
<column name="id" type="number">
<constraints primaryKey="true"/>
</column>
</createTable>
</changeSet>
</databaseChangeLog>
Liquibase seems to do something, except parsing my changeset. When I launch my actions, sql generated files only contains the creation of the two tables of liquibase (databasechangelog and databasechangeloglock) and that's all. The update action won't modify anything at all (not even creating the two previously mentioned tables). I'm (100%) sure that the table abcd does not exist in the database before execution.
So I think I need some help at this point, to figure out what isn't working. I tried to look at some examples from the liquibase forum, but nothing helped.
I'm currently using Maven's liquibase 3.4.0:
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.4.0</version>
</dependency>
Is there another dependency to include I missed?
One small other question is how do I include a special oracle database driver(ojdbc6.jar)?
Thank you for your answers.
EDIT 06/08/2015:
I got the logs in debug mode (deliberately changed the schema name):
DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: select count(*) from MYSCHEMA.DATABASECHANGELOGLOCK
DEBUG 06/08/15 09:28: liquibase: Create Database Lock Table
DEBUG 06/08/15 09:28: liquibase: Executing EXECUTE database command: CREATE TABLE MYSCHEMA.DATABASECHANGELOGLOCK (ID NUMBER(10) NOT NULL, LOCKED NUMBER(1) NOT NULL, LOCKGRANTED TIMESTAMP, LOCKEDBY VARCHAR2(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID))
DEBUG 06/08/15 09:28: liquibase: Created database lock table with name: MYSCHEMA.DATABASECHANGELOGLOCK
DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: select count(*) from MYSCHEMA.DATABASECHANGELOGLOCK
DEBUG 06/08/15 09:28: liquibase: Initialize Database Lock Table
DEBUG 06/08/15 09:28: liquibase: Executing EXECUTE database command: DELETE FROM MYSCHEMA.DATABASECHANGELOGLOCK
DEBUG 06/08/15 09:28: liquibase: Executing EXECUTE database command: INSERT INTO MYSCHEMA.DATABASECHANGELOGLOCK (ID, LOCKED) VALUES (1, 0)
DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: SELECT LOCKED FROM MYSCHEMA.DATABASECHANGELOGLOCK WHERE ID=1 FOR UPDATE
DEBUG 06/08/15 09:28: liquibase: Lock Database
DEBUG 06/08/15 09:28: liquibase: Executing UPDATE database command: UPDATE MYSCHEMA.DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = 'CRO09177 (xx.xx.xx.xxx)', LOCKGRANTED = to_date('2015-08-06 09:28:28', 'YYYY-MM-DD HH24:MI:SS') WHERE ID = 1 AND LOCKED = 0
INFO 06/08/15 09:28: liquibase: Successfully acquired change log lock
DEBUG 06/08/15 09:28: liquibase: Create Database Change Log Table
INFO 06/08/15 09:28: liquibase: Creating database history table with name: MYSCHEMA.DATABASECHANGELOG
DEBUG 06/08/15 09:28: liquibase: Executing EXECUTE database command: CREATE TABLE MYSCHEMA.DATABASECHANGELOG (ID VARCHAR2(255) NOT NULL, AUTHOR VARCHAR2(255) NOT NULL, FILENAME VARCHAR2(255) NOT NULL, DATEEXECUTED TIMESTAMP NOT NULL, ORDEREXECUTED NUMBER(10) NOT NULL, EXECTYPE VARCHAR2(10) NOT NULL, MD5SUM VARCHAR2(35), DESCRIPTION VARCHAR2(255), COMMENTS VARCHAR2(255), TAG VARCHAR2(255), LIQUIBASE VARCHAR2(20), CONTEXTS VARCHAR2(255), LABELS VARCHAR2(255))
DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: select count(*) from MYSCHEMA.DATABASECHANGELOG
INFO 06/08/15 09:28: liquibase: Reading from MYSCHEMA.DATABASECHANGELOG
DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: SELECT FILENAME,AUTHOR,ID,MD5SUM,DATEEXECUTED,ORDEREXECUTED,EXECTYPE,DESCRIPTION,COMMENTS,TAG,LIQUIBASE,LABELS,CONTEXTS FROM MYSCHEMA.DATABASECHANGELOG ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC
DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: select count(*) from MYSCHEMA.DATABASECHANGELOGLOCK
DEBUG 06/08/15 09:28: liquibase: Release Database Lock
DEBUG 06/08/15 09:28: liquibase: Executing UPDATE database command: UPDATE MYSCHEMA.DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
INFO 06/08/15 09:28: liquibase: Successfully released change log lock
Here at Datical we have noticed that there are some issues with Liquibase and Java 1.8. You mentioned on your post to the Liquibase user forums that you were using Java 1.8, so it is possible that Java 1.8 may be the issue. Can you try using Java 1.7 and see if you get different results? If not, you could try increasing the logging level - add a line like this after you have created your Liquibase object:
LogFactory.getInstance().getLog().setLogLevel(logLevel);
Where logLevel is the string "debug"
Most likely it is issue with XML versions.
Replace in XML header
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
to
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd
I encounter the same issue even if the question is really old, I'll try to give an answer. The code is wrong in two points:
changeset path
PrintWriter
Liquibase API doesn't give good feedback if the path is unreadable, but usually, you will see logging locks without any applied query.
Furthermore, in your code, the execution is printed in the Writer instead of executing queries.
here you can find a working example:
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(ds.getConnection()));
Liquibase liquibase = new Liquibase("./relativepathToChangeset", new FileSystemResourceAccessor(new File("basePathWhereChangeSetIsPresent")), database);
liquibase.update("");
I'm sharing the solution I found to fix changes not being applied when running liquibase update. Please note, I am not using Java, I managing my changelog as a .sql file. I am using the Snowflake JDBC driver. The thing that fixed it for me was explicitly defining the defaultCatalogName and defaultSchemaName properties in the liquibase.properties file. Simply providing these parameters in the JDBC url was insufficient. My liquibase.properties file looks like so:
changeLogFile: sql/changelog.sql
url: jdbc:snowflake://<url>?db=<database name>&schema=PUBLIC&role=SYSADMIN&warehouse=COMPUTE_WH
driver: net.snowflake.client.jdbc.SnowflakeDriver
username: <username>
password: <password>
classpath: snowflake-jdbc-3.13.14.jar
defaultCatalogName: <database name>
defaultSchemaName: PUBLIC
liquibase.hub.mode=off
I hope this helps someone who comes across this StackOverflow post like I did.
I has similar issue where the changeset wasn't being executed.. I changed the xsd version from 3.1 to 3.4 and it worked.
storing filedata via a hibernate (using postgresql or oracle 10g/11g) property mapped as
<property name="fileData" type="binary">
<column name="fileData" length="104857600" />
</property>
from a java application i need to access the length of the field from the db (i do not want to load whole the object, for performance reasons). i did not find any hibernate (hql) solution to query that information, so i decided to search for features of the different databases that were used. for postgresql i found:
select BIT_LENGTH(filedata) from table
which works perfectly (and astonishing fast). now i need something similar for the use with oracle. i already tried
select utl_raw.length(filedata) from table
and
select DBMS_LOB.GETLENGTH(filedata) from table
which both results in the error msg:
"Error: ORA-00997: illegal use of LONG datatype"
is there any possibilty to query the length of that hibernate property on an oracle db without selecting the object itself?
(hibernate creates a "long raw" field on oracle, and a "bytea" field on postgresql)
thx in advance
(addition: statement will be used in a migration-context, newly created filedata entities will get a filesize property programatically)
Well, looks like i found an answer here:
https://community.oracle.com/thread/2137593
create table temp_deleteme as select to_lob(<long raw field>) obj from <tablename>;
select dbms_lob.getlength(obj) from temp_deleteme;
after creating the tempTable i can select the filedatalength from it, write it to my entities, and delete the table again. still not really good performance, but that let the db do the work and i will not have to transfer entities to my server for only calculating the needed information.