Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8042961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:45:25+00:00 2026-06-05T04:45:25+00:00

I have a table in database and a function that takes the table’s id

  • 0

I have a table in database and a function that takes the table’s id and returns some number, for instance (I use Oracle syntax, but I believe RDMS doesn’t really matter in this case),

CREATE TABLE test1( test1_id INT NOT NULL PRIMARY KEY,
val VARCHAR(50));
CREATE FUNCTION getNum (id IN test1.test1_id%type) RETURN NUMBER IS ....

In my hibernate data object class I want to add a property which holds result of function execution. What is the right way to do so using annotations ?

@javax.persistence.Table(name = "test1", schema = "test", catalog = "")
@Entity
public class Test1Entity
{
      private int test1Id;
      @Column(name = "test1_id", nullable = false, insertable = true, 
      updatable = true, length = 22, precision = 0)
      @Id
      //get/set
      ...

      // is it possible to use annotations, 
      // so it will call a function to populate this field ?
      private BigDecimal test_num; 
}

I was thinking about creating naming native query , something like SELECT a.test1_id, a.val, getNum(a.test1_id) as test_num FROM test1 a WHERE a.test1_id = :param_test1_id, but it means I cannot use Session.get for reading object from DB.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:45:26+00:00Added an answer on June 5, 2026 at 4:45 am

    Use this:

    @Formula( "getNum(test1_id)" )
    private BigDecimal test_num; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table which is full-text indexed and i use the CONTAINS-function
I have a table in database that is having some fields one of which
So I have this function that takes all the users from an MySql table
I have a clojure program that at some point executes a function called db-rebuild-files-table
I have a php function that dynamically queries a database, and returns 6 tables.
I have written a function to print database table to an array like this
that my problem: I have database table like that: id (AI) market_id 1 6
I have a database table with a field that I need to read from
I have a function that takes a string object name and I need the
So I have this function that gets data from database and echoes it. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.