Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datahub project Datahub HasOwners Mixin

From Leeroopedia


Knowledge Sources
Domains Java_SDK, Metadata_Management
Last Updated 2026-02-10 00:00 GMT

Overview

Description

HasOwners is a mixin interface in the DataHub Java SDK V2 that provides ownership management operations for entities. Entities implementing this interface can have owners assigned with different ownership types (e.g., DATA_OWNER, TECHNICAL_OWNER).

The interface supports two mutation strategies:

  • Patch-based (addOwner() / removeOwner()): Uses OwnershipPatchBuilder for incremental modifications, enabling safe concurrent additions and removals.
  • Full replacement (setOwners()): Creates a complete MetadataChangeProposalWrapper replacing all existing owners, with an automatically generated audit stamp.

The interface uses the self-bounded generic pattern (T extends Entity & HasOwners<T>) for fluent API chaining.

Usage

Entity classes implement this interface to gain ownership management capabilities. Owners are identified by URN (user or group) and require an OwnershipType. The getOwners() method retrieves current owners via lazy aspect loading.

Code Reference

Source Location

metadata-integration/java/datahub-client/src/main/java/datahub/client/v2/entity/HasOwners.java

Signature

public interface HasOwners<T extends Entity & HasOwners<T>> {

    @Nonnull
    default T addOwner(@Nonnull String ownerUrn, @Nonnull OwnershipType type)

    @Nonnull
    default T addOwner(@Nonnull Urn ownerUrn, @Nonnull OwnershipType type)

    @Nonnull
    default T removeOwner(@Nonnull String ownerUrn)

    @Nonnull
    default T removeOwner(@Nonnull Urn ownerUrn)

    @Nonnull
    default T setOwners(@Nonnull List<Owner> owners)

    default List<Owner> getOwners()
}

Import

import datahub.client.v2.entity.HasOwners;

I/O Contract

Inputs

Method Parameter Type Description
addOwner ownerUrn String URN string of the owner (user or group)
addOwner type OwnershipType The ownership type (e.g., DATA_OWNER, TECHNICAL_OWNER)
addOwner ownerUrn Urn URN object of the owner
removeOwner ownerUrn String URN string of the owner to remove
removeOwner ownerUrn Urn URN object of the owner to remove
setOwners owners List<Owner> Complete list of owners to set

Outputs

Method Return Type Description
addOwner T The entity itself for fluent chaining
removeOwner T The entity itself for fluent chaining
setOwners T The entity itself for fluent chaining
getOwners List<Owner> (nullable) The list of owners, or null if none present

Exceptions:

  • InvalidUrnException - thrown if a URN string cannot be parsed

Usage Examples

Dataset dataset = Dataset.builder()
    .platform("snowflake")
    .name("my_table")
    .build();

// Add owners with ownership types (patch-based)
dataset.addOwner("urn:li:corpuser:johndoe", OwnershipType.DATA_OWNER);
dataset.addOwner("urn:li:corpuser:janedoe", OwnershipType.TECHNICAL_OWNER);

// Remove an owner
dataset.removeOwner("urn:li:corpuser:johndoe");

// Set all owners at once (full replacement)
Owner owner = new Owner();
owner.setOwner(Urn.createFromString("urn:li:corpuser:admin"));
owner.setType(OwnershipType.DATA_OWNER);
dataset.setOwners(Arrays.asList(owner));

// Retrieve current owners
List<Owner> owners = dataset.getOwners();

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment